Skip to content

Commit 9d15fd6

Browse files
committed
add test cases
1 parent a9a07b7 commit 9d15fd6

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

e2e/esm/index.e2e.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,26 @@ describe('defineTypeFactory', () => {
613613
}[];
614614
}>();
615615
});
616+
it('with traits', async () => {
617+
const BookFactory = defineBookFactory.withTransientFields({
618+
prefix: 'Foo-',
619+
})({
620+
defaultFields: {
621+
id: dynamic(async ({ get }) => `${(await get('prefix')) ?? ''}Book`),
622+
},
623+
traits: {
624+
trait: {
625+
defaultFields: {
626+
prefix: 'Bar-',
627+
},
628+
},
629+
},
630+
});
631+
const book1 = await BookFactory.build();
632+
const book2 = await BookFactory.use('trait').build();
633+
expect(book1.id).toBe('Foo-Book');
634+
expect(book2.id).toBe('Bar-Book');
635+
});
616636
});
617637
describe('resetAllSequence', () => {
618638
it('resets all sequence', async () => {

0 commit comments

Comments
 (0)