From eb0cf85c6f2b07173b214f74fc28d03926002545 Mon Sep 17 00:00:00 2001 From: Matt Travi Date: Tue, 6 Feb 2024 14:33:58 -0600 Subject: [PATCH] feat(date-options): enabled passing options through to `change.date()` Co-authored-by: Julie Van Kirk Co-authored-by: May Liang --- src/base.js | 2 +- test/unit/base-test.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/base.js b/src/base.js index 58d522c2..1c9721ff 100644 --- a/src/base.js +++ b/src/base.js @@ -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); diff --git a/test/unit/base-test.js b/test/unit/base-test.js index a8275456..5206e2f5 100644 --- a/test/unit/base-test.js +++ b/test/unit/base-test.js @@ -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); });