Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
bc7f0c9
commit efdbf3b
Showing
5 changed files
with
74 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
# The script runs the DST tests. | ||
# | ||
# It's a part of the test process. | ||
|
||
set -ex | ||
|
||
export PATH="$(yarn bin):$PATH" | ||
|
||
env TZ=America/Sao_Paulo babel-node ./test/dst/toDate/basic.js | ||
env TZ=Pacific/Apia babel-node ./test/dst/toDate/samoa.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,8 @@ then | |
|
||
yarn test -- --single-run | ||
|
||
./scripts/test/dst.sh | ||
|
||
prebuild | ||
./scripts/test/tz.sh | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// This is basic DST test for toDate | ||
|
||
import toDate from '../../../src/toDate' | ||
import assert from 'assert' | ||
|
||
if (process.env.TZ !== 'America/Sao_Paulo') | ||
throw new Error('The test must be run with TZ=America/Sao_Paulo') | ||
|
||
if (parseInt(process.version.match(/^v(\d+)\./)[1]) < 10) | ||
throw new Error('The test must be run on Node.js version >= 10') | ||
|
||
// Test DST start edge | ||
assert.equal(toDate('2018-11-03').getDate(), 3) | ||
assert.equal(toDate('2018-11-04').getDate(), 4) // DST start | ||
assert.equal(toDate('2018-11-05').getDate(), 5) | ||
|
||
// Test DST end edge | ||
assert.equal(toDate('2019-02-15').getDate(), 15) | ||
assert.equal(toDate('2019-02-16').getDate(), 16) // DST end | ||
assert.equal(toDate('2019-02-17').getDate(), 17) | ||
|
||
// Test creation of nonexistent time | ||
assert.equal( | ||
toDate('2018-11-04T00:00').toString(), | ||
'Sun Nov 04 2018 01:00:00 GMT-0200 (Brasilia Summer Time)' | ||
) | ||
assert.equal( | ||
toDate('2018-11-04T00:30').toString(), | ||
'Sun Nov 04 2018 01:30:00 GMT-0200 (Brasilia Summer Time)' | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// This is basic DST test for toDate | ||
|
||
import toDate from '../../../src/toDate' | ||
import assert from 'assert' | ||
|
||
if (process.env.TZ !== 'Pacific/Apia') | ||
throw new Error('The test must be run with TZ=Pacific/Apia') | ||
|
||
if (parseInt(process.version.match(/^v(\d+)\./)[1]) < 10) | ||
throw new Error('The test must be run on Node.js version >= 10') | ||
|
||
assert.equal(toDate('2011-12-30').getDate(), 31) | ||
assert.equal( | ||
toDate('2011-12-30T03:30').toString(), | ||
'Sat Dec 31 2011 03:30:00 GMT+1400 (Apia Daylight Time)' | ||
) |