24 lines
908 B
JavaScript
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');
|
|
});
|
|
});
|