monolito_djanco_poonto/tests/unit/auth.spec.js
Thaís Ferreira f3317dc54f 11h33
2025-01-30 11:33:58 -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();
});
});