Skip to content

Commit

Permalink
Merge pull request #1752 from travi/date-options
Browse files Browse the repository at this point in the history
feat(date-options): enabled passing options through to `change.date()`
  • Loading branch information
travi authored Feb 6, 2024
2 parents f496553 + eb0cf85 commit c5fafb5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const paragraph = options => chance.paragraph(!isPrimitive(options) ? opt
export const url = options => chance.url(!isPrimitive(options) ? options : undefined);
export const boolean = options => chance.bool(!isPrimitive(options) ? options : undefined);
export const email = options => chance.email(!isPrimitive(options) ? options : undefined);
export const date = () => chance.date({string: true});
export const date = options => chance.date({string: true, ...options});
export const fromList = list => chance.pickone(list);
export const subList = (list, {size}) => chance.pickset(list, size);

Expand Down
7 changes: 7 additions & 0 deletions test/unit/base-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,13 @@ suite('base generators', () => {
const date = chance.date();
chanceStub.date.withArgs({string: true}).returns(date);

assert.equal(any.date(), date);
});

test('that options can be passed through the date factory to the chance method', () => {
const date = chance.date();
chanceStub.date.withArgs({string: true, ...options}).returns(date);

assert.equal(any.date(options), date);
});

Expand Down

0 comments on commit c5fafb5

Please sign in to comment.