grafana/public/app/core/reducers/navModel.test.ts

42 lines
1.1 KiB
TypeScript
Raw Normal View History

import { reducerTester } from '../../../test/core/redux/reducerTester';
import { initialState, navIndexReducer, updateNavIndex } from './navModel';
import { NavIndex } from '@grafana/data';
describe('applicationReducer', () => {
describe('when updateNavIndex is dispatched', () => {
it('then state should be correct', () => {
reducerTester<NavIndex>()
.givenReducer(navIndexReducer, { ...initialState })
.whenActionIsDispatched(
updateNavIndex({
id: 'parent',
text: 'Some Text',
children: [
{
id: 'child',
text: 'Child',
},
],
})
)
.thenStateShouldEqual({
...initialState,
child: {
id: 'child',
text: 'Child',
parentItem: {
id: 'parent',
text: 'Some Text',
children: [
{
id: 'child',
text: 'Child',
},
],
},
},
});
});
});
});