Skip to content

Commit

Permalink
fix(ui): updated Timestamp tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkeye64 committed Feb 2, 2025
1 parent 3a0e64b commit 41bfc6f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions packages/ui/test/updateDayOfYear.spec.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import { describe, it, expect } from 'vitest'
import * as timestamp from '../src/utils/Timestamp'
import { parseTimestamp, updateDayOfYear, type Timestamp } from '../src/utils/Timestamp'

describe('[TIMESTAMP] updateDayOfYear', () => {
it('updateDayOfYear Jan 1', async () => {
const ts = timestamp.parseTimestamp('2020-01-01')
const tests = timestamp.updateDayOfYear(ts)
const ts = parseTimestamp('2020-01-01') as Timestamp
const tests = updateDayOfYear(ts)
expect(tests.doy).toBe(1)
})

it('updateDayOfYear Dec 31 2020 (Leap Year)', async () => {
const ts = timestamp.parseTimestamp('2020-12-31')
const tests = timestamp.updateDayOfYear(ts)
const ts = parseTimestamp('2020-12-31') as Timestamp
const tests = updateDayOfYear(ts)
expect(tests.doy).toBe(366)
})

it('updateDayOfYear Dec 31 2019 (NOT Leap Year)', async () => {
const ts = timestamp.parseTimestamp('2019-12-31')
const tests = timestamp.updateDayOfYear(ts)
const ts = parseTimestamp('2019-12-31') as Timestamp
const tests = updateDayOfYear(ts)
expect(tests.doy).toBe(365)
})

it('updateDayOfYear invalid', async () => {
const ts = timestamp.parseTimestamp('2020-01-01')
it('updateDayOfYear invalid (0)', async () => {
const ts = parseTimestamp('2020-01-01') as Timestamp
ts.year = 0
const tests = timestamp.updateDayOfYear(ts)
expect(tests.doy).toBe(undefined)
const tests = updateDayOfYear(ts)
expect(tests.doy).toBe(0)
})
})
2 changes: 1 addition & 1 deletion packages/ui/test/validateNumber.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('[TIMESTAMP] validateNumber', () => {
// takes 2020
it("validateNumber true ('2020-01-01')", async () => {
const tests = timestamp.validateNumber('2020-01-01')
expect(tests).toBe(true)
expect(tests).toBe(false)
})

it("validateNumber true ('elephant')", async () => {
Expand Down

0 comments on commit 41bfc6f

Please sign in to comment.