diff --git a/utilities/Timezone.test.ts b/utilities/Timezone.test.ts index 30cd4eea91..ad4c384be8 100644 --- a/utilities/Timezone.test.ts +++ b/utilities/Timezone.test.ts @@ -1,17 +1,20 @@ import * as Timezone from './Timezone' -describe('init', () => { - test.skip('getTimezoneDropdowns', () => { +describe('Test utilities/timezone', () => { + test('getTimezoneDropdowns for Western Indonesia', () => { const result = Timezone.getTimezoneDropdowns() const nonDaylightTimezone = result.find((obj) => { - return obj.alternativeName === 'Singapore Time' + return obj.alternativeName === 'Western Indonesia Time' }) expect(result.length).not.toBeNull() expect(result.length).toBeGreaterThan(0) - expect(nonDaylightTimezone.currentTimeFormat).toEqual( - '+08:00 Singapore Time - Singapore, Woodlands, Geylang, Marine Parade', - ) // Make sure that the nonDaylightTimezone exists. + expect(nonDaylightTimezone.abbreviation).toEqual('WIB') // Make sure that the nonDaylightTimezone exists. + + expect(nonDaylightTimezone.continentCode).toEqual('AS') + expect(nonDaylightTimezone.continentName).toEqual('Asia') + expect(nonDaylightTimezone.countryCode).toEqual('ID') + expect(nonDaylightTimezone.countryName).toEqual('Indonesia') }) test('getUtfOffsetInMins for an existing timezone', () => { diff --git a/utilities/duration.test.ts b/utilities/duration.test.ts new file mode 100644 index 0000000000..bace59f696 --- /dev/null +++ b/utilities/duration.test.ts @@ -0,0 +1,25 @@ +import { formatDuration } from '~/utilities/duration' + +Date.now = jest.fn(() => 1656069280) +// Date.setSeconds = jest.fn(() => 1656069280) +let localDate: number + +describe('Test utilities/duration', () => { + beforeAll(() => { + localDate = Date.now() + }) + test('call with latest date', () => { + // const argument = localDate.now() // Get unix timestamp + + const result: any = formatDuration(localDate) + expect(result).toEqual('59:14:40') + }) + test('call with 45 seconds date', () => { + const rawDate = new Date() + const argument = rawDate.setSeconds(45) // Returns unix timestamp + + const result: any = formatDuration(argument) + expect(result).not.toEqual('59:14:40') // Because date is not what we defaulted above + expect(typeof result).toBe('string') + }) +})