summaryrefslogtreecommitdiff
path: root/date-fns/src/getTime/test.ts
blob: 56bab044aa09b7dd26f9be5675b28c79f29a3971 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// @flow
/* eslint-env mocha */

import assert from 'power-assert'
import getTime from '.'

describe('getTime', function() {
  it('returns the timestamp of the given date', function() {
    const timestamp = 1483228800000
    const result = getTime(new Date(timestamp))
    assert(result === timestamp)
  })

  it('accepts a timestamp (and returns it unchanged)', function() {
    const timestamp = 804643200000
    const result = getTime(timestamp)
    assert(result === timestamp)
  })

  it('returns NaN if the given date is invalid', function() {
    const result = getTime(new Date(NaN))
    assert(isNaN(result))
  })

  it('throws TypeError exception if passed less than 1 argument', function() {
    assert.throws(getTime.bind(null), TypeError)
  })
})