monolito_djanco_poonto/TARS/tests/unit/auth.spec.js
Thaís Ferreira 4007e03478 ..
2025-01-29 11:51:17 -03:00

33 lines
869 B
JavaScript

import { createStore } from 'vuex';
import auth from '../../src/store/modules/auth';
describe('auth store module', () => {
let store;
beforeEach(() => {
store = createStore({
modules: {
auth,
},
});
});
it('should initialize with default state', () => {
expect(store.state.auth.isAuthenticated).toBe(false);
expect(store.state.auth.user).toBeNull();
});
it('should login successfully', async () => {
const user = { name: 'John Doe', email: 'john@example.com' };
store.dispatch('auth/login', user);
expect(store.state.auth.isAuthenticated).toBe(true);
expect(store.state.auth.user).toEqual(user);
});
it('should logout successfully', async () => {
store.dispatch('auth/logout');
expect(store.state.auth.isAuthenticated).toBe(false);
expect(store.state.auth.user).toBeNull();
});
});