Skip to content

Commit

Permalink
feat(jest): Add timezone unit test (#1615)
Browse files Browse the repository at this point in the history
  • Loading branch information
drepram committed Feb 22, 2022
1 parent 8710629 commit bd214d1
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions utilities/Timezone.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as Timezone from './Timezone'

describe('init', () => {
test('getTimezoneDropdowns', () => {
const result = Timezone.getTimezoneDropdowns()
const nonDaylightTimezone = result.find((obj) => {
return obj.alternativeName === 'Singapore Time'
})

expect(result.length).not.toBeNull()
expect(result.length).toBeGreaterThan(0)
expect(nonDaylightTimezone.currentTimeFormat).toEqual(
'+08:00 Singapore Time - Singapore, Woodlands, Marine Parade',
) // Make sure that the nonDaylightTimezone exists.
})
test('getUtfOffsetInMins for an existing timezone', () => {
const result = Timezone.getUtfOffsetInMins('Asia/Singapore')

expect(result).toBe(480)
})
test('getUtfOffsetInMins for a non existing timezone', () => {
const result = Timezone.getUtfOffsetInMins('Asia/Singapura')

expect(result).toBeNull()
})
})

0 comments on commit bd214d1

Please sign in to comment.