-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
59 additions
and
91 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,92 +1,75 @@ | ||
import { expect, test } from '@jest/globals' | ||
import { parse } from './eliteEarlyBirdService' | ||
import moment = require('moment-timezone') | ||
|
||
test('full time - at 13:37', async () => { | ||
const now = new Date() | ||
const midnight = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0).getTime() | ||
const result = parse('13:37:37.137') | ||
expect(result).toBeDefined() | ||
if (result) { | ||
expect(result - midnight).toBe(13 * 60 * 60 * 1000 + 37 * 60 * 1000 + 37 * 1000 + 137) | ||
expect(result).toBe(moment.tz('13:37:37.137', 'hh:mm:ss.SSS', 'Europe/Berlin').valueOf()) | ||
} | ||
}) | ||
|
||
test('full time - early morning', async () => { | ||
const now = new Date() | ||
const midnight = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0).getTime() | ||
const result = parse('2:37:37.137') | ||
expect(result).toBeDefined() | ||
if (result) { | ||
expect(result - midnight).toBe(2 * 60 * 60 * 1000 + 37 * 60 * 1000 + 37 * 1000 + 137) | ||
expect(result).toBe(moment.tz('02:37:37.137', 'hh:mm:ss.SSS', 'Europe/Berlin').valueOf()) | ||
} | ||
}) | ||
|
||
test('full time - early morning - single digits', async () => { | ||
const now = new Date() | ||
const midnight = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0).getTime() | ||
const result = parse('2:02:02.1') | ||
expect(result).toBeDefined() | ||
if (result) { | ||
expect(result - midnight).toBe(2 * 60 * 60 * 1000 + 2 * 60 * 1000 + 2 * 1000 + 100) | ||
expect(result).toBe(moment.tz('02:02:02.100', 'hh:mm:ss.SSS', 'Europe/Berlin').valueOf()) | ||
} | ||
}) | ||
|
||
test('time without millis - early morning - single digits', async () => { | ||
const now = new Date() | ||
const midnight = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0).getTime() | ||
const result = parse('2:02:02') | ||
expect(result).toBeDefined() | ||
if (result) { | ||
expect(result - midnight).toBe(2 * 60 * 60 * 1000 + 2 * 60 * 1000 + 2 * 1000) | ||
expect(result).toBe(moment.tz('02:02:02', 'hh:mm:ss', 'Europe/Berlin').valueOf()) | ||
} | ||
}) | ||
|
||
test('time without hour - single digits', async () => { | ||
const now = new Date() | ||
const midnight = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0).getTime() | ||
const result = parse('2:02') | ||
expect(result).toBeDefined() | ||
if (result) { | ||
expect(result - midnight).toBe(13 * 60 * 60 * 1000 + 2 * 60 * 1000 + 2 * 1000) | ||
expect(result).toBe(moment.tz('13:02:02', 'hh:mm:ss', 'Europe/Berlin').valueOf()) | ||
} | ||
}) | ||
|
||
test('time just in seconcs', async () => { | ||
const now = new Date() | ||
const midnight = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0).getTime() | ||
const result = parse('37') | ||
expect(result).toBeDefined() | ||
if (result) { | ||
expect(result - midnight).toBe(13 * 60 * 60 * 1000 + 37 * 60 * 1000 + 37 * 1000) | ||
expect(result).toBe(moment.tz('13:37:37', 'hh:mm:ss', 'Europe/Berlin').valueOf()) | ||
} | ||
}) | ||
|
||
test('time just in seconcs and millis(3 digit pending 0)', async () => { | ||
const now = new Date() | ||
const midnight = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0).getTime() | ||
const result = parse('3.370') | ||
expect(result).toBeDefined() | ||
if (result) { | ||
expect(result - midnight).toBe(13 * 60 * 60 * 1000 + 37 * 60 * 1000 + 3 * 1000 + 370) | ||
expect(result).toBe(moment.tz('13:37:03.370', 'hh:mm:ss.SSS', 'Europe/Berlin').valueOf()) | ||
} | ||
}) | ||
|
||
test('time just in seconcs and millis(2 digits)', async () => { | ||
const now = new Date() | ||
const midnight = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0).getTime() | ||
const result = parse('3.37') | ||
expect(result).toBeDefined() | ||
if (result) { | ||
expect(result - midnight).toBe(13 * 60 * 60 * 1000 + 37 * 60 * 1000 + 3 * 1000 + 370) | ||
expect(result).toBe(moment.tz('13:37:03.37', 'hh:mm:ss.SS', 'Europe/Berlin').valueOf()) | ||
} | ||
}) | ||
|
||
test('time just in seconcs and millis(3 digits, leading 0)', async () => { | ||
const now = new Date() | ||
const midnight = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0).getTime() | ||
const result = parse('3.037') | ||
expect(result).toBeDefined() | ||
if (result) { | ||
expect(result - midnight).toBe(13 * 60 * 60 * 1000 + 37 * 60 * 1000 + 3 * 1000 + 37) | ||
expect(result).toBe(moment.tz('13:37:03.037', 'hh:mm:ss.SSS', 'Europe/Berlin').valueOf()) | ||
} | ||
}) |
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