monolito_djanco_poonto/tests/unit/users.spec.js
Thaís Ferreira f3317dc54f 11h33
2025-01-30 11:33:58 -03:00

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();
});
});