Enhance Vitest configuration and improve Vue integration
- Added Vue plugin to vitest.config.ts for better component testing. - Introduced vitest.setup.ts to expose Vue reactivity and lifecycle methods globally, ensuring compatibility with .vue components. - Updated mock implementations in nuxt-imports.ts to include readonly for improved reactivity handling. - Refactored useMapBookmarks and useToast composables to utilize readonly from Vue for better state management.
This commit is contained in:
@@ -4,29 +4,36 @@ import type L from 'leaflet'
|
||||
import type { Map, LayerGroup } from 'leaflet'
|
||||
import { createCharacter, type CharacterData, type CharacterMapViewRef } from '../Character'
|
||||
|
||||
vi.mock('leaflet', () => {
|
||||
const { leafletMock } = vi.hoisted(() => {
|
||||
const markerMock = {
|
||||
on: vi.fn().mockReturnThis(),
|
||||
addTo: vi.fn().mockReturnThis(),
|
||||
setLatLng: vi.fn().mockReturnThis(),
|
||||
setIcon: vi.fn().mockReturnThis(),
|
||||
}
|
||||
return {
|
||||
default: {
|
||||
marker: vi.fn(() => markerMock),
|
||||
Icon: vi.fn().mockImplementation(() => ({})),
|
||||
},
|
||||
const Icon = vi.fn().mockImplementation(function (this: unknown) {
|
||||
return {}
|
||||
})
|
||||
const L = {
|
||||
marker: vi.fn(() => markerMock),
|
||||
Icon: vi.fn().mockImplementation(() => ({})),
|
||||
Icon,
|
||||
}
|
||||
return { leafletMock: L }
|
||||
})
|
||||
|
||||
vi.mock('leaflet', () => ({
|
||||
__esModule: true,
|
||||
default: leafletMock,
|
||||
marker: leafletMock.marker,
|
||||
Icon: leafletMock.Icon,
|
||||
}))
|
||||
|
||||
vi.mock('~/lib/LeafletCustomTypes', () => ({
|
||||
HnHMaxZoom: 6,
|
||||
}))
|
||||
|
||||
function getL(): L {
|
||||
return require('leaflet').default
|
||||
return leafletMock as unknown as L
|
||||
}
|
||||
|
||||
function makeCharData(overrides: Partial<CharacterData> = {}): CharacterData {
|
||||
|
||||
Reference in New Issue
Block a user