Skip to content

Commit

Permalink
fix: datatype.datetime should use static boundaries
Browse files Browse the repository at this point in the history
  • Loading branch information
ST-DDT committed Jan 29, 2022
1 parent a717637 commit 1a3e2d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/datatype.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ export class Datatype {
options = options || {};

if (typeof options.min === 'undefined' || options.min < minMax * -1) {
options.min = new Date().setFullYear(1990, 1, 1);
options.min = Date.UTC(1990, 0);
}

if (typeof options.max === 'undefined' || options.max > minMax) {
options.max = new Date().setFullYear(2100, 1, 1);
options.max = Date.UTC(2100, 0);
}

const random = this.faker.datatype.number(options);
Expand Down
6 changes: 6 additions & 0 deletions test/datatype.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ describe('datatype', () => {
spy_datatype_number.mockRestore();
});

it('should generate a datetime value, checks seeding', () => {
faker.seed(100);
const generatedDateTime = faker.datatype.datetime();
expect(generatedDateTime).toEqual(new Date('2049-10-10T09:07:31.031Z'));
});

//generating a datetime with seeding is currently not working
});

Expand Down

0 comments on commit 1a3e2d1

Please sign in to comment.