This repository has been archived on 2023-12-22. You can view files and clone it, but cannot push or open issues or pull requests.
old-monorepo/_Dashboard/test/actions/user.spec.js

54 lines
1.1 KiB
JavaScript

import { expect } from 'chai';
import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import actions from '../../app/renderer/actions/user';
const mockStore = configureMockStore([thunk]);
describe('actions', () => {
describe('user', () => {
it('should log in', () => {
const store = mockStore({});
const expectedActions = [
{
type: 'USER_LOGIN',
payload: {
username: 'John Doe',
loggedIn: true,
},
},
];
store.dispatch(
actions.login({
username: 'John Doe',
loggedIn: true,
}),
);
expect(store.getActions()).deep.equal(expectedActions);
});
it('should logout', () => {
const store = mockStore({});
const expectedActions = [
{
type: 'USER_LOGOUT',
payload: {
username: '',
loggedIn: false,
},
},
];
store.dispatch(
actions.logout({
username: '',
loggedIn: false,
}),
);
expect(store.getActions()).deep.equal(expectedActions);
});
});
});