File tree Expand file tree Collapse file tree 3 files changed +5
-8
lines changed Expand file tree Collapse file tree 3 files changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -253,15 +253,15 @@ contactFactory.rewindSequence();
253
253
254
254
### Derived Attributes
255
255
256
- Attributes can be derived from other attributes with the ` params ` option.
256
+ Attributes can be derived from other attributes with the ` entity ` option.
257
257
258
258
` ` ` typescript
259
259
const userFactory = createFactory <User >({
260
260
id: 1 ,
261
261
firstName: ' Alice' ,
262
262
lastName: ' Smith' ,
263
- fullName({ params }) {
264
- return ` ${params .firstName } ${params .lastName } ` ;
263
+ fullName({ entity }) {
264
+ return ` ${entity .firstName } ${entity .lastName } ` ;
265
265
},
266
266
});
267
267
Original file line number Diff line number Diff line change @@ -643,8 +643,8 @@ describe('DSL', () => {
643
643
. attributes < { id : number ; name : string } > ( { id : 1 , name : 'name' } )
644
644
. trait ( 'evenOdd' , ( trait ) =>
645
645
trait . attributes ( {
646
- name ( { params } ) {
647
- return ( params ?. id ?? 0 ) % 2 === 0 ? 'even' : 'odd' ;
646
+ name ( { entity } ) {
647
+ return ( entity ?. id ?? 0 ) % 2 === 0 ? 'even' : 'odd' ;
648
648
} ,
649
649
} )
650
650
)
Original file line number Diff line number Diff line change @@ -48,7 +48,6 @@ type AttributeBuilder<
48
48
) => Entity [ Property ] ;
49
49
type AttributeBuilderParams < Entity , TransientParams > = {
50
50
sequence : number ;
51
- params : Partial < Entity > ;
52
51
entity : Entity ;
53
52
transientParams : TransientParams ;
54
53
} ;
@@ -275,7 +274,6 @@ export function createFactory<
275
274
if ( typeof attribute === 'function' ) {
276
275
entity [ key ] = attribute ( {
277
276
sequence : definition . sequence . count ,
278
- params : { ...attributes , ...entity } ,
279
277
entity : globalAttributeProxy ,
280
278
transientParams,
281
279
} ) ;
@@ -310,7 +308,6 @@ export function createFactory<
310
308
if ( typeof attribute === 'function' ) {
311
309
entity [ key ] = attribute ( {
312
310
sequence : definition . sequence . count ,
313
- params : { ...attributes , ...entity } ,
314
311
entity : traitAttributeProxy ,
315
312
transientParams : {
316
313
...trait . transientParamDefaults ,
You can’t perform that action at this time.
0 commit comments