30 lines
996 B
TypeScript
30 lines
996 B
TypeScript
|
|
import { describe, it, expect } from "vitest";
|
||
|
|
import { filterNewResults } from "../admin.sports-seasons.$id.events.$eventId.helpers";
|
||
|
|
|
||
|
|
describe("filterNewResults", () => {
|
||
|
|
it("returns all rows when no existing results", () => {
|
||
|
|
const incoming = [
|
||
|
|
{ participantId: "p1", placement: 1 },
|
||
|
|
{ participantId: "p2", placement: 2 },
|
||
|
|
];
|
||
|
|
expect(filterNewResults(incoming, new Set())).toEqual(incoming);
|
||
|
|
});
|
||
|
|
|
||
|
|
it("skips participantIds already in existingIds", () => {
|
||
|
|
const incoming = [
|
||
|
|
{ participantId: "p1", placement: 1 },
|
||
|
|
{ participantId: "p2", placement: 2 },
|
||
|
|
];
|
||
|
|
const existing = new Set(["p1"]);
|
||
|
|
expect(filterNewResults(incoming, existing)).toEqual([
|
||
|
|
{ participantId: "p2", placement: 2 },
|
||
|
|
]);
|
||
|
|
});
|
||
|
|
|
||
|
|
it("returns empty array when all are duplicates", () => {
|
||
|
|
const incoming = [{ participantId: "p1", placement: 1 }];
|
||
|
|
const existing = new Set(["p1"]);
|
||
|
|
expect(filterNewResults(incoming, existing)).toEqual([]);
|
||
|
|
});
|
||
|
|
});
|