import { getDate , dispatchDateChange } from '../../src/core/util/method' ; import defaultOptions from '../../src/store/default-options' ; import { createState } from '../../src/store' ; const startDate = '1999/10/1' ; const endDate = '2000/10/1' ; describe ( 'getDate' , ( ) => { const state = createState ( defaultOptions ( ) ) ; it ( 'should get actions of `State`' , ( ) => { expect ( getDate ( state ) ) . toBeNull ( ) ; } ) ; it ( 'if `State` type has `range`, return a actions array' , ( ) => { state . options . type = 'date-range' ; state . start . date = startDate ; state . end . date = endDate ; expect ( getDate ( state ) ) . toEqual ( [ new Date ( startDate ) , new Date ( endDate ) ] ) ; } ) ; } ) ; describe ( 'dispatchDateChange' , ( ) => { const state = createState ( defaultOptions ( ) ) ; it ( 'should be called when actions has changed' , ( ) => { const fn = jest . fn ( ) ; state . onChange = fn ; dispatchDateChange . call ( state ) ; expect ( fn ) . toBeCalled ( ) ; } ) ; } ) ;