kmcom-nuxt-layers 5.0.6 → 5.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,23 +3,29 @@ import type {
|
|
|
3
3
|
MetadataSearchInput,
|
|
4
4
|
MetadataSearchResult,
|
|
5
5
|
} from '#layers/metadata/shared/types'
|
|
6
|
+
import type * as CacheModule from './cache'
|
|
6
7
|
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
vi.
|
|
9
|
+
// search.ts imports its sibling helpers directly. Keep the pure cache helpers real, and
|
|
10
|
+
// control provider/cache lookups via mocks.
|
|
11
|
+
const { providerState, getProvidersMock, getSearchCacheMock, setSearchCacheMock } = vi.hoisted(
|
|
12
|
+
() => {
|
|
13
|
+
const providerState: { mockProviders: MetadataProvider[] } = { mockProviders: [] }
|
|
14
|
+
return {
|
|
15
|
+
providerState,
|
|
16
|
+
getProvidersMock: vi.fn(() => providerState.mockProviders),
|
|
17
|
+
getSearchCacheMock: vi.fn(async () => null as MetadataSearchResult[] | null),
|
|
18
|
+
setSearchCacheMock: vi.fn(async () => undefined),
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
vi.mock('./provider-registry', () => ({ getProviders: getProvidersMock }))
|
|
24
|
+
vi.mock('./cache', async (importOriginal) => ({
|
|
25
|
+
...(await importOriginal<typeof CacheModule>()),
|
|
26
|
+
getSearchCache: getSearchCacheMock,
|
|
27
|
+
setSearchCache: setSearchCacheMock,
|
|
28
|
+
}))
|
|
23
29
|
|
|
24
30
|
const { searchMetadata } = await import('./search')
|
|
25
31
|
|
package/package.json
CHANGED