File tree 2 files changed +29
-2
lines changed
2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change 1
- export const isObject = o => o != null && typeof o === 'object' ;
1
+ export const isDate = d => d instanceof Date ;
2
2
export const isEmpty = o => Object . keys ( o ) . length === 0 ;
3
+ export const isObject = o => o != null && typeof o === 'object' ;
Original file line number Diff line number Diff line change 1
1
import { expect } from 'chai' ;
2
2
import forEach from 'mocha-each' ;
3
3
4
- import { isEmpty , isObject } from './' ;
4
+ import { isDate , isEmpty , isObject } from './' ;
5
5
6
6
describe ( 'utils' , ( ) => {
7
7
8
+ describe ( '.isDate' , ( ) => {
9
+ forEach ( [
10
+ [ new Date ( ) ] ,
11
+ [ new Date ( '2016' ) ] ,
12
+ [ new Date ( '2016-01' ) ] ,
13
+ [ new Date ( '2016-01-01' ) ] ,
14
+ [ new Date ( '2016-01-01:14:45:20' ) ] ,
15
+ [ new Date ( 'Tue Feb 14 2017 14:45:20 GMT+0000 (GMT)' ) ] ,
16
+ [ new Date ( 'nonsense' ) ] ,
17
+ ] ) . it ( 'returns true when given a date object of %s' , ( date ) => {
18
+ expect ( isDate ( date ) ) . to . be . true ;
19
+ } ) ;
20
+
21
+ forEach ( [
22
+ [ 100 ] ,
23
+ [ '100' ] ,
24
+ [ false ] ,
25
+ [ { a : 100 } ] ,
26
+ [ [ 100 , 101 , 102 ] ] ,
27
+ [ Date . parse ( '2016' ) ] ,
28
+ [ Date . now ( ) ] ,
29
+ ] ) . it ( 'returns false when not given a date object of %s' , ( x ) => {
30
+ expect ( isDate ( x ) ) . to . be . false ;
31
+ } ) ;
32
+ } ) ;
33
+
8
34
describe ( '.isEmpty' , ( ) => {
9
35
describe ( 'returns true' , ( ) => {
10
36
it ( 'when given an empty object' , ( ) => {
You can’t perform that action at this time.
0 commit comments