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(); }); });