soupette d0d18b22e1 Created hook to get layout
Signed-off-by: soupette <cyril.lpz@gmail.com>
2020-07-08 10:58:07 +02:00

84 lines
1.8 KiB
JavaScript

import reducer from '../reducer';
describe('ADMIN | HOOKS | useFetchPermissionsLayout | reducer', () => {
describe('DEFAULT_ACTION', () => {
it('should return the initialState', () => {
const state = {
test: true,
};
expect(reducer(state, {})).toEqual(state);
});
});
describe('GET_DATA_ERROR', () => {
it('should set isLoading to false is an error occured', () => {
const action = {
type: 'GET_DATA_ERROR',
error: {
message: 'error',
},
};
const initialState = {
data: {},
error: null,
isLoading: true,
};
const expected = {
data: {},
error: { message: 'error' },
isLoading: false,
};
expect(reducer(initialState, action)).toEqual(expected);
});
});
describe('GET_DATA', () => {
it('should set isLoading to true ', () => {
const action = {
type: 'GET_DATA',
};
const initialState = {
data: {
ok: true,
},
error: true,
isLoading: true,
};
const expected = {
data: {},
error: null,
isLoading: true,
};
expect(reducer(initialState, action)).toEqual(expected);
});
});
describe('GET_DATA_SUCCEEDED', () => {
it('should return the state with the data', () => {
const action = {
type: 'GET_DATA_SUCCEEDED',
data: {
ok: true,
},
};
const initialState = {
data: {},
error: true,
isLoading: true,
};
const expected = {
data: {
ok: true,
},
error: null,
isLoading: false,
};
expect(reducer(initialState, action)).toEqual(expected);
});
});
});