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

25 lines
938 B
JavaScript

import { mount } from '@vue/test-utils';
import UsersView from '../../src/views/UsersView.vue';
import store from '../../src/store';
describe('UsersView', () => {
it('should display users list', async () => {
const wrapper = mount(UsersView, { global: { plugins: [store] } });
await store.dispatch('users/fetchUsers');
expect(wrapper.findAll('.user').length).toBeGreaterThan(0);
});
it('should add a user', async () => {
const wrapper = mount(UsersView, { global: { plugins: [store] } });
await store.dispatch('users/addUser', { id: 3, name: 'New User', group: 'User', permission: 'Limited' });
expect(wrapper.text()).toContain('New User');
});
it('should delete a user', async () => {
const userId = 1;
const wrapper = mount(UsersView, { global: { plugins: [store] } });
await store.dispatch('users/deleteUser', userId);
expect(wrapper.text()).not.toContain('João Silva');
});
});