Skip to content

Commit

Permalink
Add test case for duplicate ID imports
Browse files Browse the repository at this point in the history
  • Loading branch information
glmdgrielson committed Nov 5, 2024
1 parent 95bf2c9 commit 453a014
Show file tree
Hide file tree
Showing 2 changed files with 1,213 additions and 1 deletion.
26 changes: 25 additions & 1 deletion lib/domains/character/CharacterFactory.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import produce from "immer";
import { CharacterFactory } from "./CharacterFactory";
import { DefaultTemplates } from "./DefaultTemplates";
import { ComplexCharacter } from "./mocks/ComplexCharacter";
import { DuplicateIds } from "./mocks/DuplicateIds";
import { Warden } from "./mocks/WardenLeMagane";
import { IV1Character } from "./types";
import { ICharacter, IV1Character } from "./types";

describe("CharacterFactory.migrate", () => {
describe("v1", () => {
Expand Down Expand Up @@ -649,6 +650,29 @@ describe("CharacterFactory.migrate", () => {
version: 6,
});
});

it("should handle DuplicateIds", () => {
const result = CharacterFactory.makeFromJson(DuplicateIds);

const ids = [result.id];

for (const page of result.pages) {
ids.push(page.id);
for (const row of page.rows) {
for (const column of row.columns) {
for (const section of column.sections) {
ids.push(section.id);
for (const block of section.blocks) {
ids.push(block.id);
}
}
}
}
}

// This should check for duplicates
expect(new Set(ids).size).toEqual(ids.length);
});
});
});

Expand Down
Loading

0 comments on commit 453a014

Please sign in to comment.