2017-10-10 16:26:38 +02:00
|
|
|
import { expect } from 'chai';
|
2021-12-17 22:26:52 +01:00
|
|
|
import { State } from '../interfaces/state';
|
2017-10-10 16:26:38 +02:00
|
|
|
import * as actions from './misc';
|
|
|
|
|
2017-10-29 19:56:24 +01:00
|
|
|
describe('actions/misc', () => {
|
2017-10-10 16:26:38 +02:00
|
|
|
describe('clearAll action', () => {
|
|
|
|
it('returns CLEAR_ALL action', () => {
|
2019-12-23 19:22:54 +01:00
|
|
|
const expectedAction: actions.ClearAllAction = {
|
2017-10-10 16:26:38 +02:00
|
|
|
type: 'CLEAR_ALL',
|
|
|
|
};
|
|
|
|
|
|
|
|
expect(actions.clearAll()).to.eql(expectedAction);
|
|
|
|
});
|
|
|
|
});
|
2019-11-03 14:18:16 +01:00
|
|
|
|
|
|
|
describe('resetTo action', () => {
|
|
|
|
it('returns RESET_TO action', () => {
|
2019-12-23 19:22:54 +01:00
|
|
|
const state: State = {
|
|
|
|
choices: [],
|
|
|
|
items: [],
|
|
|
|
groups: [],
|
|
|
|
loading: false,
|
|
|
|
};
|
|
|
|
const expectedAction: actions.ResetToAction = {
|
2019-11-03 14:18:16 +01:00
|
|
|
type: 'RESET_TO',
|
|
|
|
state,
|
|
|
|
};
|
|
|
|
|
|
|
|
expect(actions.resetTo(state)).to.eql(expectedAction);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('setIsLoading action', () => {
|
|
|
|
describe('setting loading state to true', () => {
|
|
|
|
it('returns expected action', () => {
|
2019-12-23 19:22:54 +01:00
|
|
|
const expectedAction: actions.SetIsLoadingAction = {
|
2019-11-03 14:18:16 +01:00
|
|
|
type: 'SET_IS_LOADING',
|
|
|
|
isLoading: true,
|
|
|
|
};
|
|
|
|
|
|
|
|
expect(actions.setIsLoading(true)).to.eql(expectedAction);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('setting loading state to false', () => {
|
|
|
|
it('returns expected action', () => {
|
2019-12-23 19:22:54 +01:00
|
|
|
const expectedAction: actions.SetIsLoadingAction = {
|
2019-11-03 14:18:16 +01:00
|
|
|
type: 'SET_IS_LOADING',
|
|
|
|
isLoading: false,
|
|
|
|
};
|
|
|
|
|
|
|
|
expect(actions.setIsLoading(false)).to.eql(expectedAction);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2017-10-10 16:26:38 +02:00
|
|
|
});
|