Fix lint in new QP change-detection tests
Replace inline import() type annotations with top-level `import type * as` (consistent-type-imports) and use toSorted() over sort() (unicorn/no-array-sort) in the tests added for diffChangedQualifyingPoints. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hq3fG4Zn3unntbSQAGSqCq
This commit is contained in:
parent
21c6fd6229
commit
9fda6310bc
3 changed files with 6 additions and 4 deletions
|
|
@ -19,7 +19,7 @@ describe("diffChangedQualifyingPoints", () => {
|
||||||
{ id: "C", qp: "3.00" }, // first-time score
|
{ id: "C", qp: "3.00" }, // first-time score
|
||||||
];
|
];
|
||||||
|
|
||||||
expect([...diffChangedQualifyingPoints(before, after)].sort()).toEqual(["B", "C"]);
|
expect([...diffChangedQualifyingPoints(before, after)].toSorted()).toEqual(["B", "C"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("normalizes decimal formatting so 10 and 10.00 are equal", () => {
|
it("normalizes decimal formatting so 10 and 10.00 are equal", () => {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||||
|
import type * as QualifyingPointsModule from "~/models/qualifying-points";
|
||||||
|
|
||||||
// Spy on the QP Discord notification, and no-op the per-participant total recalc
|
// Spy on the QP Discord notification, and no-op the per-participant total recalc
|
||||||
// (its own eventResults query would otherwise interfere with the before/after
|
// (its own eventResults query would otherwise interfere with the before/after
|
||||||
|
|
@ -8,7 +9,7 @@ vi.mock("~/services/qualifying-points-discord.server", () => ({
|
||||||
}));
|
}));
|
||||||
|
|
||||||
vi.mock("~/models/qualifying-points", async (importActual) => {
|
vi.mock("~/models/qualifying-points", async (importActual) => {
|
||||||
const actual = await importActual<typeof import("~/models/qualifying-points")>();
|
const actual = await importActual<typeof QualifyingPointsModule>();
|
||||||
return {
|
return {
|
||||||
...actual,
|
...actual,
|
||||||
recalculateParticipantQP: vi.fn().mockResolvedValue({ totalQP: 0, eventsScored: 0 }),
|
recalculateParticipantQP: vi.fn().mockResolvedValue({ totalQP: 0, eventsScored: 0 }),
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||||
|
import type * as QualifyingPointsModule from "~/models/qualifying-points";
|
||||||
|
|
||||||
// The helper under test re-derives QP via processQualifyingBracketEvent and
|
// The helper under test re-derives QP via processQualifyingBracketEvent and
|
||||||
// recalculates dropped participants — both stubbed so the test drives the
|
// recalculates dropped participants — both stubbed so the test drives the
|
||||||
|
|
@ -13,7 +14,7 @@ vi.mock("~/models/scoring-calculator", () => ({
|
||||||
// Keep the real diffChangedQualifyingPoints (the change-detection primitive under
|
// Keep the real diffChangedQualifyingPoints (the change-detection primitive under
|
||||||
// test here); only stub the dropped-participant total recalc.
|
// test here); only stub the dropped-participant total recalc.
|
||||||
vi.mock("~/models/qualifying-points", async (importActual) => {
|
vi.mock("~/models/qualifying-points", async (importActual) => {
|
||||||
const actual = await importActual<typeof import("~/models/qualifying-points")>();
|
const actual = await importActual<typeof QualifyingPointsModule>();
|
||||||
return {
|
return {
|
||||||
...actual,
|
...actual,
|
||||||
recalculateParticipantQP: vi.fn().mockResolvedValue(undefined),
|
recalculateParticipantQP: vi.fn().mockResolvedValue(undefined),
|
||||||
|
|
@ -69,7 +70,7 @@ describe("rescoreTennisBracketAndDetectChanges", () => {
|
||||||
|
|
||||||
const changed = await rescoreTennisBracketAndDetectChanges(EVENT_ID, SPORTS_SEASON_ID, db as never);
|
const changed = await rescoreTennisBracketAndDetectChanges(EVENT_ID, SPORTS_SEASON_ID, db as never);
|
||||||
|
|
||||||
expect([...changed].sort()).toEqual(["B", "C"]);
|
expect([...changed].toSorted()).toEqual(["B", "C"]);
|
||||||
expect(processQualifyingBracketEvent).toHaveBeenCalledWith(EVENT_ID, db);
|
expect(processQualifyingBracketEvent).toHaveBeenCalledWith(EVENT_ID, db);
|
||||||
// No participant dropped out, so no manual total recalc.
|
// No participant dropped out, so no manual total recalc.
|
||||||
expect(recalculateParticipantQP).not.toHaveBeenCalled();
|
expect(recalculateParticipantQP).not.toHaveBeenCalled();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue