-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix time formatting on transactions (#2854)
- Loading branch information
1 parent
60380bb
commit ef1a953
Showing
4 changed files
with
64 additions
and
34 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
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,31 @@ | ||
import { toDateFormat } from './date'; | ||
|
||
const TZ = 'America/Toronto'; | ||
|
||
describe('Date', () => { | ||
describe('toDateFormat', () => { | ||
it('should be America/Toronto timeZone', () => { | ||
// we're explicitly setting TZ in `jest.config.js` | ||
// this test is to verify that | ||
expect(Intl.DateTimeFormat().resolvedOptions().timeZone).toBe(TZ); | ||
}); | ||
it('should format date correctly', () => { | ||
// if TZ is not 'America/Toronto' the following test cases will fail | ||
expect(toDateFormat(1592877684000)).toBe('Jun 22 at 10:01 pm'); | ||
expect(toDateFormat(1592877340000)).toBe('Jun 22 at 9:55 pm'); | ||
expect(toDateFormat(1592850067000)).toBe('Jun 22 at 2:21 pm'); | ||
expect(toDateFormat(1615308615000)).toBe('Mar 9 at 11:50 am'); | ||
expect(toDateFormat(1615308108000)).toBe('Mar 9 at 11:41 am'); | ||
// this was previously rendering as 0:28 pm: | ||
expect(toDateFormat(1615912139000)).toBe('Mar 16 at 12:28 pm'); | ||
expect(toDateFormat(1592883929000)).toBe('Jun 22 at 11:45 pm'); | ||
expect(toDateFormat(1592883518000)).toBe('Jun 22 at 11:38 pm'); | ||
expect(toDateFormat(1592882817000)).toBe('Jun 22 at 11:26 pm'); | ||
expect(toDateFormat(1592881746000)).toBe('Jun 22 at 11:09 pm'); | ||
expect(toDateFormat(1592879617000)).toBe('Jun 22 at 10:33 pm'); | ||
expect(toDateFormat(1592879267000)).toBe('Jun 22 at 10:27 pm'); | ||
expect(toDateFormat(1592879146000)).toBe('Jun 22 at 10:25 pm'); | ||
expect(toDateFormat(1592878450000)).toBe('Jun 22 at 10:14 pm'); | ||
}); | ||
}); | ||
}); |
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,23 @@ | ||
process.env.TZ = 'America/Toronto'; | ||
|
||
const config = { | ||
preset: 'react-native', | ||
setupFiles: ['<rootDir>/app/util/testSetup.js'], | ||
transform: { | ||
'^.+\\.js$': '<rootDir>jest.preprocessor.js' | ||
}, | ||
transformIgnorePatterns: [ | ||
'node_modules/(?!(react-native|rn-fetch|redux-persist-filesystem|@react-navigation|@react-native-community|react-navigation|react-navigation-redux-helpers|@sentry))' | ||
], | ||
snapshotSerializers: ['enzyme-to-json/serializer'], | ||
collectCoverage: false, | ||
collectCoverageFrom: [ | ||
'<rootDir>/app/**/*.{js,jsx}', | ||
'!<rootDir>/node_modules/', | ||
'!<rootDir>/app/util/*.{js,jsx}', | ||
'!<rootDir>/app/entry*.js' | ||
] | ||
}; | ||
|
||
// eslint-disable-next-line import/no-commonjs | ||
module.exports = config; |
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