import { topTopics } from './topic.reducer' ; import { testData } from 'test/data' ; import { Topic } from 'shared-library/shared/model' ; import { TopicActions } from '../actions' ; describe ( 'TopicReducer: topTopics' , ( ) => { const _testReducer = topTopics ; it ( 'Initial State' , ( ) => { const state = _testReducer ( undefined , { type : null , payload : null } ) ; expect ( state ) . toEqual ( [ ] ) ; } ) ; it ( 'Verify topTopics function when action type is `LOAD_TOP_TOPICS_SUCCESS`' , ( ) => { const categoryData = [ ] ; const topics = [ ] ; categoryData . push ( testData . categoryDictionary ) ; categoryData . map ( ( data ) => { topics [ data . id ] = data ; } ) ; const newState = _testReducer ( topics , { type : TopicActions . LOAD_TOP_TOPICS_SUCCESS , payload : topics } ) ; expect ( newState ) . toEqual ( topics ) ; } ) ; } ) ;