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

24 lines
908 B
JavaScript

import { mount } from '@vue/test-utils';
import LoginView from '../../src/views/LoginView.vue';
describe('LoginView', () => {
it('should display login form', () => {
const wrapper = mount(LoginView);
expect(wrapper.find('form').exists()).toBe(true);
});
it('should login with correct credentials', async () => {
const wrapper = mount(LoginView);
await wrapper.setData({ email: 'test@example.com', password: 'password' });
await wrapper.find('form').trigger('submit');
expect(wrapper.vm.$route.name).toBe('dashboard'); // Assuming the route after login is dashboard
});
it('should show error with invalid credentials', async () => {
const wrapper = mount(LoginView);
await wrapper.setData({ email: 'invalid@example.com', password: 'wrong' });
await wrapper.find('form').trigger('submit');
expect(wrapper.text()).toContain('Invalid credentials');
});
});