Standardize store exports to named useXxxStore convention
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,7 @@ vi.mock('@/module/apiError.js', () => ({
|
||||
}));
|
||||
|
||||
import Login from '@/views/Login/Login.vue';
|
||||
import loginStore from '@/stores/login.ts';
|
||||
import { useLoginStore } from '@/stores/login.ts';
|
||||
|
||||
describe('Login', () => {
|
||||
let pinia;
|
||||
@@ -46,7 +46,7 @@ describe('Login', () => {
|
||||
|
||||
it('enables login button when both fields have values', async () => {
|
||||
const wrapper = mountLogin();
|
||||
const store = loginStore();
|
||||
const store = useLoginStore();
|
||||
store.auth.username = 'user';
|
||||
store.auth.password = 'pass';
|
||||
await wrapper.vm.$nextTick();
|
||||
@@ -56,7 +56,7 @@ describe('Login', () => {
|
||||
|
||||
it('shows error message when isInvalid', async () => {
|
||||
const wrapper = mountLogin();
|
||||
const store = loginStore();
|
||||
const store = useLoginStore();
|
||||
store.isInvalid = true;
|
||||
await wrapper.vm.$nextTick();
|
||||
expect(wrapper.text()).toContain('Incorrect account or password');
|
||||
@@ -64,7 +64,7 @@ describe('Login', () => {
|
||||
|
||||
it('toggles password visibility', async () => {
|
||||
const wrapper = mountLogin();
|
||||
const store = loginStore();
|
||||
const store = useLoginStore();
|
||||
store.auth.password = 'secret';
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
@@ -86,7 +86,7 @@ describe('Login', () => {
|
||||
const wrapper = mountLogin({
|
||||
route: { query: { 'return-to': 'encodedUrl' } },
|
||||
});
|
||||
const store = loginStore();
|
||||
const store = useLoginStore();
|
||||
expect(store.rememberedReturnToUrl).toBe('encodedUrl');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -16,7 +16,7 @@ vi.mock('@/api/client.js', () => ({
|
||||
vi.mock('@/stores/login.ts', () => {
|
||||
const { defineStore } = require('pinia');
|
||||
return {
|
||||
default: defineStore('loginStore', {
|
||||
useLoginStore: defineStore('loginStore', {
|
||||
state: () => ({
|
||||
userData: { username: 'currentUser', name: 'Current' },
|
||||
}),
|
||||
@@ -27,7 +27,7 @@ vi.mock('@/stores/login.ts', () => {
|
||||
};
|
||||
});
|
||||
|
||||
import useAcctMgmtStore from '@/stores/acctMgmt.ts';
|
||||
import { useAcctMgmtStore } from '@/stores/acctMgmt.ts';
|
||||
|
||||
describe('acctMgmtStore', () => {
|
||||
let store;
|
||||
|
||||
@@ -12,7 +12,7 @@ vi.mock('@/api/client.js', () => ({
|
||||
default: { get: mockGet, post: mockPost, put: mockPut },
|
||||
}));
|
||||
|
||||
import useAllMapDataStore from '@/stores/allMapData.js';
|
||||
import { useAllMapDataStore } from '@/stores/allMapData.js';
|
||||
|
||||
describe('allMapDataStore', () => {
|
||||
let store;
|
||||
|
||||
@@ -10,7 +10,7 @@ vi.mock('@/api/client.js', () => ({
|
||||
default: { get: mockGet },
|
||||
}));
|
||||
|
||||
import useCompareStore from '@/stores/compare.js';
|
||||
import { useCompareStore } from '@/stores/compare.js';
|
||||
|
||||
describe('compareStore', () => {
|
||||
let store;
|
||||
|
||||
@@ -13,7 +13,7 @@ vi.mock('@/api/client.js', () => ({
|
||||
}));
|
||||
|
||||
import apiError from '@/module/apiError.js';
|
||||
import useConformanceStore from '@/stores/conformance.js';
|
||||
import { useConformanceStore } from '@/stores/conformance.js';
|
||||
|
||||
describe('conformanceStore', () => {
|
||||
let store;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
import { setActivePinia, createPinia } from 'pinia';
|
||||
import useConformanceInputStore from '@/stores/conformanceInput.js';
|
||||
import { useConformanceInputStore } from '@/stores/conformanceInput.js';
|
||||
|
||||
describe('conformanceInputStore', () => {
|
||||
let store;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
||||
import { setActivePinia, createPinia } from 'pinia';
|
||||
import useCytoscapeStore from '@/stores/cytoscapeStore.ts';
|
||||
import { useCytoscapeStore } from '@/stores/cytoscapeStore.ts';
|
||||
import { SAVE_KEY_NAME } from '@/constants/constants.js';
|
||||
|
||||
// Mock localStorage since jsdom's localStorage is limited
|
||||
|
||||
@@ -28,7 +28,7 @@ vi.mock('@/api/client.js', () => ({
|
||||
default: { get: mockGet, post: mockPost, put: mockPut, delete: mockDelete },
|
||||
}));
|
||||
|
||||
import useFilesStore from '@/stores/files.js';
|
||||
import { useFilesStore } from '@/stores/files.js';
|
||||
|
||||
describe('filesStore', () => {
|
||||
let store;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
import { setActivePinia, createPinia } from 'pinia';
|
||||
import useLoadingStore from '@/stores/loading.js';
|
||||
import { useLoadingStore } from '@/stores/loading.js';
|
||||
|
||||
describe('loadingStore', () => {
|
||||
let store;
|
||||
|
||||
@@ -13,7 +13,7 @@ vi.mock('@/api/client.js', () => ({
|
||||
default: { get: mockClientGet },
|
||||
}));
|
||||
|
||||
import useLoginStore from '@/stores/login.ts';
|
||||
import { useLoginStore } from '@/stores/login.ts';
|
||||
|
||||
// Mock axios methods (used for signIn/refreshToken which call plain axios)
|
||||
vi.spyOn(axios, 'post').mockImplementation(vi.fn());
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
import { setActivePinia, createPinia } from 'pinia';
|
||||
import useMapCompareStore from '@/stores/mapCompareStore.ts';
|
||||
import { useMapCompareStore } from '@/stores/mapCompareStore.ts';
|
||||
|
||||
describe('mapCompareStore', () => {
|
||||
let store;
|
||||
|
||||
@@ -16,7 +16,7 @@ vi.mock('@/assets/capsule2.svg', () => ({ default: 'cap2' }));
|
||||
vi.mock('@/assets/capsule3.svg', () => ({ default: 'cap3' }));
|
||||
vi.mock('@/assets/capsule4.svg', () => ({ default: 'cap4' }));
|
||||
|
||||
import useMapPathStore from '@/stores/mapPathStore.ts';
|
||||
import { useMapPathStore } from '@/stores/mapPathStore.ts';
|
||||
|
||||
/**
|
||||
* Creates a mock Cytoscape node.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
import { setActivePinia, createPinia } from 'pinia';
|
||||
import usePageAdminStore from '@/stores/pageAdmin.js';
|
||||
import { usePageAdminStore } from '@/stores/pageAdmin.js';
|
||||
|
||||
describe('pageAdminStore', () => {
|
||||
let store;
|
||||
|
||||
@@ -10,7 +10,7 @@ vi.mock('@/api/client.js', () => ({
|
||||
default: { get: mockGet },
|
||||
}));
|
||||
|
||||
import usePerformanceStore from '@/stores/performance.js';
|
||||
import { usePerformanceStore } from '@/stores/performance.js';
|
||||
|
||||
describe('performanceStore', () => {
|
||||
let store;
|
||||
|
||||
@@ -3,16 +3,16 @@ import { setActivePinia, createPinia } from 'pinia';
|
||||
|
||||
// Mock all heavy imports that MainContainer.vue pulls in
|
||||
vi.mock('@/stores/loading.js', () => ({
|
||||
default: () => ({ isLoading: false }),
|
||||
useLoadingStore: () => ({ isLoading: false }),
|
||||
}));
|
||||
vi.mock('@/stores/allMapData.js', () => ({
|
||||
default: () => ({}),
|
||||
useAllMapDataStore: () => ({}),
|
||||
}));
|
||||
vi.mock('@/stores/conformance.js', () => ({
|
||||
default: () => ({}),
|
||||
useConformanceStore: () => ({}),
|
||||
}));
|
||||
vi.mock('@/stores/pageAdmin.js', () => ({
|
||||
default: () => ({}),
|
||||
usePageAdminStore: () => ({}),
|
||||
}));
|
||||
vi.mock('@/module/alertModal.js', () => ({
|
||||
leaveFilter: vi.fn(),
|
||||
@@ -26,7 +26,7 @@ vi.mock('@/router/index.ts', () => ({
|
||||
}));
|
||||
vi.mock('@/module/cytoscapeMap.js', () => ({}));
|
||||
|
||||
import LoginStore from '@/stores/login.ts';
|
||||
import { useLoginStore } from '@/stores/login.ts';
|
||||
import * as cookieUtil from '@/utils/cookieUtil.js';
|
||||
|
||||
// Import the component definition to access beforeRouteEnter
|
||||
@@ -38,7 +38,7 @@ describe('MainContainer beforeRouteEnter', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
setActivePinia(createPinia());
|
||||
loginStore = LoginStore();
|
||||
loginStore = useLoginStore();
|
||||
loginStore.$router = { push: vi.fn() };
|
||||
next = vi.fn();
|
||||
vi.clearAllMocks();
|
||||
|
||||
Reference in New Issue
Block a user