Skip to content

Commit

Permalink
Tests: Fix failing test on master due to DST (#12046)
Browse files Browse the repository at this point in the history
The `getLocalizedDate` test began failing when the timezone switched in the USA.

This updates the post-schedule component tests to use a fixed date for timezone calculations.
  • Loading branch information
jordwest authored Mar 13, 2017
1 parent 3ee6cfc commit b3f9047
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions client/components/post-schedule/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,21 @@ describe( 'gmtOffset', () => {
} );

describe( 'getLocalizedDate', () => {
// Use a fixed "now" to prevent issues with DST
const now = new Date( 2017, 1, 1, 0, 0, 0 );

it( 'Should return a date localized at Amsterdam (utc: 60 minutes)', () => {
const nowInAmsterdam = getLocalizedDate( new Date(), 'Europe/Amsterdam' );
const nowInAmsterdam = getLocalizedDate( now, 'Europe/Amsterdam' );
expect( nowInAmsterdam.utcOffset() ).to.equal( 60 );
} );

it( 'Should return a date localized at New York (utc: -300 minutes)', () => {
const nowInNewYork = getLocalizedDate( new Date(), 'America/New_York' );
const nowInNewYork = getLocalizedDate( now, 'America/New_York' );
expect( nowInNewYork.utcOffset() ).to.equal( -300 );
} );

it( 'Should return a date localized at UTC+3:30 (utc: 210 minutes)', () => {
const NowAtUTC3_30 = getLocalizedDate( new Date(), false, 210 );
const NowAtUTC3_30 = getLocalizedDate( now, false, 210 );
expect( NowAtUTC3_30.utcOffset() ).to.equal( 210 );
} );
} );
Expand Down

0 comments on commit b3f9047

Please sign in to comment.