File tree Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Expand file tree Collapse file tree 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 ;
22export 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 11import { expect } from 'chai' ;
22import forEach from 'mocha-each' ;
33
4- import { isEmpty , isObject } from './' ;
4+ import { isDate , isEmpty , isObject } from './' ;
55
66describe ( 'utils' , ( ) => {
77
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+
834 describe ( '.isEmpty' , ( ) => {
935 describe ( 'returns true' , ( ) => {
1036 it ( 'when given an empty object' , ( ) => {
You can’t perform that action at this time.
0 commit comments