Show only the newest repository when replies arrive out of order
Every reload and every open takes a number before asking git; a reply is used only if no newer request was sent after it, and an out-of-date error is not shown. Commit details and diffs that come back after another repository was opened are neither kept nor shown.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { tickets } from "./latest";
|
||||
|
||||
describe("tickets", () => {
|
||||
it("treats the only ticket taken as the newest", () => {
|
||||
const t = tickets();
|
||||
const a = t.take();
|
||||
expect(t.isLatest(a)).toBe(true);
|
||||
});
|
||||
it("treats an older ticket as out of date once a newer one is taken", () => {
|
||||
const t = tickets();
|
||||
const older = t.take();
|
||||
const newer = t.take();
|
||||
expect(t.isLatest(older)).toBe(false);
|
||||
expect(t.isLatest(newer)).toBe(true);
|
||||
});
|
||||
it("keeps an older ticket out of date after more tickets are taken", () => {
|
||||
const t = tickets();
|
||||
const first = t.take();
|
||||
t.take();
|
||||
const last = t.take();
|
||||
expect(t.isLatest(first)).toBe(false);
|
||||
expect(t.isLatest(last)).toBe(true);
|
||||
});
|
||||
it("keeps separate sets of tickets apart", () => {
|
||||
const a = tickets();
|
||||
const b = tickets();
|
||||
const fromA = a.take();
|
||||
b.take();
|
||||
b.take();
|
||||
expect(a.isLatest(fromA)).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user