Add store tests with mocked axios and apiError

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 19:30:33 +08:00
parent 83c2db7582
commit 529e9a4aa1
12 changed files with 1260 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
import { describe, it, expect, beforeEach } from 'vitest';
import { setActivePinia, createPinia } from 'pinia';
import useConformanceInputStore from '@/stores/conformanceInput.js';
describe('conformanceInputStore', () => {
let store;
beforeEach(() => {
setActivePinia(createPinia());
store = useConformanceInputStore();
});
it('has correct default state', () => {
expect(store.inputDataToSave.inputStart).toBeNull();
expect(store.activityRadioData.task).toEqual(['', '']);
});
it('setActivityRadioStartEndData sets From', () => {
store.setActivityRadioStartEndData('taskA', 'From');
expect(store.activityRadioData.task[0]).toBe('taskA');
});
it('setActivityRadioStartEndData sets To', () => {
store.setActivityRadioStartEndData('taskB', 'To');
expect(store.activityRadioData.task[1]).toBe('taskB');
});
it('setActivityRadioStartEndData ignores unknown', () => {
store.setActivityRadioStartEndData('taskC', 'Unknown');
expect(store.activityRadioData.task).toEqual(['', '']);
});
});