Skip to content

Commit 2ca2206

Browse files
committed
remove params option
1 parent c7b4905 commit 2ca2206

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,15 +253,15 @@ contactFactory.rewindSequence();
253253
254254
### Derived Attributes
255255
256-
Attributes can be derived from other attributes with the `params` option.
256+
Attributes can be derived from other attributes with the `entity` option.
257257
258258
```typescript
259259
const userFactory = createFactory<User>({
260260
id: 1,
261261
firstName: 'Alice',
262262
lastName: 'Smith',
263-
fullName({ params }) {
264-
return `${params.firstName} ${params.lastName}`;
263+
fullName({ entity }) {
264+
return `${entity.firstName} ${entity.lastName}`;
265265
},
266266
});
267267

src/__tests__/factory.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,8 +643,8 @@ describe('DSL', () => {
643643
.attributes<{ id: number; name: string }>({ id: 1, name: 'name' })
644644
.trait('evenOdd', (trait) =>
645645
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';
648648
},
649649
})
650650
)

src/factory.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ type AttributeBuilder<
4848
) => Entity[Property];
4949
type AttributeBuilderParams<Entity, TransientParams> = {
5050
sequence: number;
51-
params: Partial<Entity>;
5251
entity: Entity;
5352
transientParams: TransientParams;
5453
};
@@ -275,7 +274,6 @@ export function createFactory<
275274
if (typeof attribute === 'function') {
276275
entity[key] = attribute({
277276
sequence: definition.sequence.count,
278-
params: { ...attributes, ...entity },
279277
entity: globalAttributeProxy,
280278
transientParams,
281279
});
@@ -310,7 +308,6 @@ export function createFactory<
310308
if (typeof attribute === 'function') {
311309
entity[key] = attribute({
312310
sequence: definition.sequence.count,
313-
params: { ...attributes, ...entity },
314311
entity: traitAttributeProxy,
315312
transientParams: {
316313
...trait.transientParamDefaults,

0 commit comments

Comments
 (0)