test: configure Vitest and add 54 unit tests (F6.1, F6.2)
Set up Vitest with happy-dom, mock Nuxt auto-imports via #imports alias. Add tests for: inventory-types validators (9), apiHelpers (10), modelUtils (18), useConfirm (8), useToast (9). All 54 tests pass. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
35
tests/__mocks__/imports.ts
Normal file
35
tests/__mocks__/imports.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Minimal mock for Nuxt's #imports auto-import.
|
||||
* Add stubs here as tests require them.
|
||||
*/
|
||||
|
||||
import { ref } from 'vue'
|
||||
|
||||
export const useRuntimeConfig = () => ({
|
||||
public: {
|
||||
apiBaseUrl: 'http://localhost:8081/api',
|
||||
appVersion: '0.0.0-test',
|
||||
},
|
||||
})
|
||||
|
||||
export const useRoute = () => ({
|
||||
path: '/',
|
||||
params: {},
|
||||
query: {},
|
||||
})
|
||||
|
||||
export const useRouter = () => ({
|
||||
push: () => Promise.resolve(),
|
||||
replace: () => Promise.resolve(),
|
||||
})
|
||||
|
||||
export const navigateTo = () => Promise.resolve()
|
||||
|
||||
export const useRequestFetch = () => fetch
|
||||
|
||||
export const useFetch = () => ({
|
||||
data: ref(null),
|
||||
error: ref(null),
|
||||
pending: ref(false),
|
||||
refresh: () => Promise.resolve(),
|
||||
})
|
||||
Reference in New Issue
Block a user