Add store tests with mocked axios and apiError
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
27
tests/stores/loading.test.js
Normal file
27
tests/stores/loading.test.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
import { setActivePinia, createPinia } from 'pinia';
|
||||
import useLoadingStore from '@/stores/loading.js';
|
||||
|
||||
describe('loadingStore', () => {
|
||||
let store;
|
||||
|
||||
beforeEach(() => {
|
||||
setActivePinia(createPinia());
|
||||
store = useLoadingStore();
|
||||
});
|
||||
|
||||
it('has isLoading true by default', () => {
|
||||
expect(store.isLoading).toBe(true);
|
||||
});
|
||||
|
||||
it('setIsLoading sets to false', () => {
|
||||
store.setIsLoading(false);
|
||||
expect(store.isLoading).toBe(false);
|
||||
});
|
||||
|
||||
it('setIsLoading sets to true', () => {
|
||||
store.setIsLoading(false);
|
||||
store.setIsLoading(true);
|
||||
expect(store.isLoading).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user