mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 10:24:05 +00:00
feat(map): amap as map api provider and display template
This commit is contained in:
@@ -51,6 +51,7 @@ const {
|
||||
mockCacheGetInFlight,
|
||||
mockCacheSetInFlight,
|
||||
mockServeFilePath,
|
||||
mockProviderGet,
|
||||
} = vi.hoisted(() => ({
|
||||
mockDbGet: vi.fn((..._args: unknown[]) => undefined as any),
|
||||
mockDbRun: vi.fn(),
|
||||
@@ -59,6 +60,12 @@ const {
|
||||
// row holds a key", and would otherwise have its stub eaten by the
|
||||
// app_settings lookup.
|
||||
mockInstanceGet: vi.fn((..._args: unknown[]) => undefined as any),
|
||||
// The places_provider row is read before the key chain, so it needs a seam of
|
||||
// its own: routed through mockInstanceGet it would eat the mockReturnValueOnce
|
||||
// that a case meant for the instance-wide KEY, and the service would resolve a
|
||||
// key value as a provider name. Default undefined = the 'auto' choice, which is
|
||||
// what every install that predates Amap has.
|
||||
mockProviderGet: vi.fn((..._args: unknown[]) => undefined as any),
|
||||
preparedSql: [] as string[],
|
||||
mockCheckSsrf: vi.fn(async (_url: string, _bypassInternalIpAllowed?: boolean): Promise<SsrfCheckStub> => ({
|
||||
allowed: true,
|
||||
@@ -83,7 +90,12 @@ vi.mock('../../../src/db/database', () => ({
|
||||
prepare: (sql: string) => {
|
||||
preparedSql.push(sql);
|
||||
return {
|
||||
get: (...args: unknown[]) => (sql.includes('app_settings') ? mockInstanceGet(...args) : mockDbGet(...args)),
|
||||
get: (...args: unknown[]) => {
|
||||
if (!sql.includes('app_settings')) return mockDbGet(...args);
|
||||
// Keyed by the bound parameter, not just by the table: app_settings
|
||||
// holds both the instance-wide API keys and the provider choice.
|
||||
return args[0] === 'places_provider' ? mockProviderGet(...args) : mockInstanceGet(...args);
|
||||
},
|
||||
all: vi.fn(() => []),
|
||||
run: mockDbRun,
|
||||
};
|
||||
@@ -195,6 +207,8 @@ afterEach(() => {
|
||||
mockDbGet.mockReturnValue(undefined);
|
||||
mockInstanceGet.mockReset();
|
||||
mockInstanceGet.mockReturnValue(undefined);
|
||||
mockProviderGet.mockReset();
|
||||
mockProviderGet.mockReturnValue(undefined);
|
||||
preparedSql.length = 0;
|
||||
mockDbRun.mockReset();
|
||||
mockCheckSsrf.mockReset();
|
||||
|
||||
Reference in New Issue
Block a user