File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -613,6 +613,26 @@ describe('defineTypeFactory', () => {
613
613
} [ ] ;
614
614
} > ( ) ;
615
615
} ) ;
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
+ } ) ;
616
636
} ) ;
617
637
describe ( 'resetAllSequence' , ( ) => {
618
638
it ( 'resets all sequence' , async ( ) => {
You can’t perform that action at this time.
0 commit comments