Skip to content

Commit

Permalink
fix: update factory to use path supplied (#502)
Browse files Browse the repository at this point in the history
  • Loading branch information
spaenleh authored Apr 29, 2024
1 parent d397ab3 commit f4b15eb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/item/factory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ describe('Base Item Factory', () => {
'3d11f9d9_fbbe_4e0a_9a13_0999ca20bebc.2d11f9d9_fbbe_4e0a_9a13_0999ca20bebc',
);
});
it('Return path supplied', () => {
const itemPath =
'2d11f9d9_fbbe_4e0a_9a13_0999ca20bebc.2d11f9d9_fbbe_4e0a_9a13_0999ca20beba';
const item = PartialItemFactory({
id: '2d11f9d9-fbbe-4e0a-9a13-0999ca20bebc',
path: itemPath,
});
expect(item.path).toEqual(itemPath);
});

it('Allow null creator', () => {
const item1 = PartialItemFactory({
Expand Down
1 change: 1 addition & 0 deletions src/item/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const PartialItemFactory = <IT extends DiscriminatedItem>(
item.updatedAt ?? faker.date.anytime().toISOString();

const path =
item.path ??
(item.parentItem ? item.parentItem.path + '.' : '') + buildPathFromIds(id);

return {
Expand Down

0 comments on commit f4b15eb

Please sign in to comment.