first commit
This commit is contained in:
39
frontend/tests/auth.spec.js
Normal file
39
frontend/tests/auth.spec.js
Normal file
@@ -0,0 +1,39 @@
|
||||
import { describe, it, expect, beforeEach, vi } from "vitest";
|
||||
import { useAuthStore } from "../../src/stores/authStore";
|
||||
import { createPinia, setActivePinia } from "pinia";
|
||||
|
||||
describe("Auth Store", () => {
|
||||
beforeEach(() => {
|
||||
setActivePinia(createPinia());
|
||||
});
|
||||
|
||||
it("should initialize with no user", () => {
|
||||
const store = useAuthStore();
|
||||
expect(store.isAuthenticated).toBe(false);
|
||||
expect(store.user).toBeNull();
|
||||
});
|
||||
|
||||
it("should store user data on login", () => {
|
||||
const store = useAuthStore();
|
||||
|
||||
// Mock user data
|
||||
const mockUser = {
|
||||
id: "123",
|
||||
email: "test@example.com",
|
||||
username: "testuser",
|
||||
};
|
||||
|
||||
// In a real test, you'd mock the API call
|
||||
// For now, just test the store structure
|
||||
expect(store.user).toBeNull();
|
||||
});
|
||||
|
||||
it("should clear user data on logout", () => {
|
||||
const store = useAuthStore();
|
||||
store.logout();
|
||||
|
||||
expect(store.isAuthenticated).toBe(false);
|
||||
expect(store.user).toBeNull();
|
||||
expect(store.accessToken).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user