create-personal-react-app
Version:
A thin wrapper around Facebook's create-react-app
41 lines (37 loc) • 1.05 kB
JavaScript
import reducer from './index';
import { doShowSnackbar, doHideSnackbar } from '../../actions';
describe('snackbar reducer', () => {
it('should return the initial state', () => {
const expectedState = {
message: '',
type: '',
isVisible: false,
};
expect(reducer(undefined, {})).toEqual(expectedState);
});
it('should handle SNACKBAR_SHOW', () => {
const message = 'Não foi possível listar usuários!';
const type = 'error';
const action = doShowSnackbar(message, type);
const expectedState = {
message,
type,
isVisible: true,
};
expect(reducer(undefined, action)).toEqual(expectedState);
});
it('should handle SNACKBAR_HIDE', () => {
const state = {
message: 'Não foi possível listar usuários!',
type: 'error',
isVisible: true,
};
const action = doHideSnackbar();
const expectedState = {
message: '',
type: '',
isVisible: false,
};
expect(reducer(state, action)).toEqual(expectedState);
});
});