27 lines
700 B
JavaScript
27 lines
700 B
JavaScript
import { createStore } from 'vuex';
|
|
import users from '../../src/store/modules/users';
|
|
|
|
describe('users store module', () => {
|
|
let store;
|
|
|
|
beforeEach(() => {
|
|
store = createStore({
|
|
modules: {
|
|
users,
|
|
},
|
|
});
|
|
});
|
|
|
|
it('should add a user', async () => {
|
|
const newUser = { id: 3, name: 'Carlos Silva', group: 'User', permission: 'Limited' };
|
|
store.dispatch('users/addUser', newUser);
|
|
expect(store.state.users.users).toContainEqual(newUser);
|
|
});
|
|
|
|
it('should delete a user', async () => {
|
|
const userId = 1;
|
|
store.dispatch('users/deleteUser', userId);
|
|
expect(store.state.users.users.find((user) => user.id === userId)).toBeUndefined();
|
|
});
|
|
});
|