kmcom-nuxt-layers 5.0.6 → 5.0.8

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
- import { hashQuery, makeCacheKey } from './cache'
9
-
10
- // search.ts calls getProviders()/makeCacheKey()/hashQuery()/getSearchCache()/setSearchCache()
11
- // as Nitro auto-imports (sibling server/utils files). Stub the pure cache helpers with their
12
- // real implementations, and control provider/cache lookups directly via mocks.
13
- const providerState: { mockProviders: MetadataProvider[] } = { mockProviders: [] }
14
- const getProvidersMock = vi.fn(() => providerState.mockProviders)
15
- const getSearchCacheMock = vi.fn(async () => null as MetadataSearchResult[] | null)
16
- const setSearchCacheMock = vi.fn(async () => undefined)
17
-
18
- vi.stubGlobal('getProviders', getProvidersMock)
19
- vi.stubGlobal('makeCacheKey', makeCacheKey)
20
- vi.stubGlobal('hashQuery', hashQuery)
21
- vi.stubGlobal('getSearchCache', getSearchCacheMock)
22
- vi.stubGlobal('setSearchCache', setSearchCacheMock)
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kmcom-nuxt-layers",
3
3
  "private": false,
4
- "version": "5.0.6",
4
+ "version": "5.0.8",
5
5
  "description": "Composable Nuxt 4 layers for building scalable Vue applications",
6
6
  "exports": {
7
7
  "./layers/core": "./layers/core/nuxt.config.ts",