Skip to content

Commit

Permalink
Update test for DateFromUnixTime
Browse files Browse the repository at this point in the history
  • Loading branch information
Sævar Berg authored and gcanti committed Mar 23, 2021
1 parent 9c2c670 commit ba2303d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions test/DateFromUnixTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { DateFromUnixTime } from '../src'
import { assertSuccess, assertFailure } from './helpers'
import { either } from 'fp-ts/lib/Either'

const d = new Date(1973, 10, 30)
const n = d.getTime()
const seconds = n / 1000
const d = new Date(1973, 10, 30, 12, 12, 12, 12)
const seconds = Math.floor(d.getTime() / 1000)

describe('DateFromUnixTime', () => {
it('is', () => {
Expand All @@ -16,8 +15,8 @@ describe('DateFromUnixTime', () => {

it('decode', () => {
const T = DateFromUnixTime
assertSuccess(T.decode(seconds), d)
assertSuccess(either.map(T.decode(seconds), d => d.getTime()), n)
assertSuccess(T.decode(seconds), new Date(seconds * 1000))
assertSuccess(either.map(T.decode(seconds), d => d.getTime()), seconds * 1000)
assertFailure(T, NaN, ['Invalid value NaN supplied to : DateFromUnixTime'])
assertFailure(T, '', ['Invalid value "" supplied to : DateFromUnixTime'])
assertFailure(T, 1.2345678901234568e79, ['Invalid value 1.2345678901234568e+79 supplied to : DateFromUnixTime'])
Expand Down

0 comments on commit ba2303d

Please sign in to comment.