Skip to content

fix: failing tests with dates in local time #4412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions spec/PushController.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1198,10 +1198,12 @@ describe('PushController', () => {
isLocalTime: false
})).toBe('2007-04-05T14:30:00.000Z', 'Timezone offset');

const noTimezone = new Date('2017-09-06T17:14:01.048')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marvelm could you have a look please? As you were originally building that feature.

Thanks!

const expectedHour = 17 + noTimezone.getTimezoneOffset() / 60;
expect(PushController.formatPushTime({
date: new Date('2017-09-06T17:14:01.048'),
date: noTimezone,
isLocalTime: true,
})).toBe('2017-09-06T17:14:01.048', 'No timezone');
})).toBe(`2017-09-06T${expectedHour}:14:01.048`, 'No timezone');
expect(PushController.formatPushTime({
date: new Date('2017-09-06'),
isLocalTime: true
Expand All @@ -1222,6 +1224,7 @@ describe('PushController', () => {
};

const pushTime = '2017-09-06T17:14:01.048';
const expectedHour = 17 + new Date(pushTime).getTimezoneOffset() / 60;

reconfigureServer({
push: {adapter: pushAdapter},
Expand All @@ -1247,7 +1250,7 @@ describe('PushController', () => {
})
.then((pushStatus) => {
expect(pushStatus.get('status')).toBe('scheduled');
expect(pushStatus.get('pushTime')).toBe('2017-09-06T17:14:01.048');
expect(pushStatus.get('pushTime')).toBe(`2017-09-06T${expectedHour}:14:01.048`);
})
.then(done, done.fail);
});
Expand Down