Skip to content

Commit

Permalink
refactoring codes
Browse files Browse the repository at this point in the history
  • Loading branch information
mizdra committed Aug 19, 2023
1 parent b155d66 commit 64d1972
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe('defineTypeFactory', () => {
const BookFactory = defineBookFactory({
defaultFields: {
id: ({ seq }) => `Book-${seq}`,
title: ({ seq }) => `ゆゆ式 ${seq}巻`,
title: 'ゆゆ式',
author: undefined,
},
});
Expand Down Expand Up @@ -156,15 +156,13 @@ describe('TypeFactoryInterface', () => {
};
}>(book1);

// partial input field
// Passing input fields allows overriding the default field.
const boo2 = await BookFactory.build({
// id: ...,
// author: ...,
title: 'ゆゆ式 1巻', // non-undefined field
title: 'ゆゆ式 100巻',
});
expect(boo2).toStrictEqual({
id: 'Book-0',
title: 'ゆゆ式 1巻',
title: 'ゆゆ式 100巻',
author: {
id: 'Author-0',
name: '三上小又',
Expand Down Expand Up @@ -216,15 +214,15 @@ describe('TypeFactoryInterface', () => {
const BookFactory = defineBookFactory({
defaultFields: {
id: ({ seq }) => `Book-${seq}`,
title: ({ seq }) => `ゆゆ式 ${seq}巻`,
title: 'ゆゆ式',
author: undefined,
},
});
expect(await BookFactory.build()).toMatchObject({ id: 'Book-0' });
expect(await BookFactory.build()).toMatchObject({ id: 'Book-1' });
BookFactory.resetSequence();
expect(await BookFactory.build()).toMatchObject({ id: 'Book-0' });
// TODO: Test other factories
});
it.todo('does not affect other factories');
});
});

0 comments on commit 64d1972

Please sign in to comment.