Skip to content

Commit

Permalink
test: fix tz UT
Browse files Browse the repository at this point in the history
  • Loading branch information
wswebcreation committed Aug 5, 2020
1 parent ddb6261 commit fb4f10d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"license": "MIT",
"scripts": {
"release": "np",
"test.unit": "jest",
"test.unit": "TZ=UTC jest",
"test.e2e": "node test/e2e.js",
"coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage"
},
Expand Down
2 changes: 1 addition & 1 deletion test/unit/__snapshots__/utils.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ exports[`formatDuration should be able determine the proper duration 1`] = `"00

exports[`formatDuration should be able determine the proper duration 2`] = `"00:00:01.993"`;

exports[`formatToLocalIso should be able to format time to local ISO 1`] = `"2020/02/17 16:27:43"`;
exports[`formatToLocalIso should be able to format time to local ISO 1`] = `"2020/02/17 15:27:43"`;
16 changes: 7 additions & 9 deletions test/unit/utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,9 @@ describe('findJsonFiles', () => {
});

describe('formatToLocalIso', () => {
// jest.mock('moment',
// () => () => jest.requireActual('moment')('2020-02-17T15:27:43.843Z')
// );

Date.now = jest.fn(() => new Date('2020-02-17T15:27:43.843Z'));
jest.mock('moment',
() => () => jest.requireActual('moment')('2020-02-17T15:27:43.843Z')
);

it('should be able to format time to local ISO', () => {
expect(formatToLocalIso('2020-02-17T15:27:43.843Z')).toMatchSnapshot();
Expand Down Expand Up @@ -189,7 +187,7 @@ describe('getCustomStyleSheet', () => {
it('should log an error when the file content could not be accessed', () => {
const fileName = './file.txt';
const error = 'Access error';
fs.accessSync.mockImplementationOnce(() => {
fs.accessSync.mockImplementationOnce(()=> {
throw new Error(error);
});
jest.spyOn(global.console, 'log');
Expand All @@ -204,7 +202,7 @@ describe('getCustomStyleSheet', () => {
const fileName = './file.txt';
const error = 'Read error';
fs.accessSync;
fs.readFileSync.mockImplementationOnce(() => {
fs.readFileSync.mockImplementationOnce(()=> {
throw new Error(error);
});
jest.spyOn(global.console, 'log');
Expand Down Expand Up @@ -241,7 +239,7 @@ describe('getStyleSheet', () => {
it('should log an error when the file content could not be accessed', () => {
const fileName = 'foo.css';
const error = 'Access error';
fs.accessSync.mockImplementationOnce(() => {
fs.accessSync.mockImplementationOnce(()=> {
throw new Error(error);
});
jest.spyOn(global.console, 'log');
Expand All @@ -256,7 +254,7 @@ describe('getStyleSheet', () => {
const fileName = 'foo.css';
const error = 'Read error';
fs.accessSync;
fs.readFileSync.mockImplementationOnce(() => {
fs.readFileSync.mockImplementationOnce(()=> {
throw new Error(error);
});
jest.spyOn(global.console, 'log');
Expand Down

0 comments on commit fb4f10d

Please sign in to comment.