mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-24 07:53:09 +00:00
@@ -14,16 +14,16 @@ const { pluginsEnabled } = vi.hoisted(() => ({
|
||||
vi.mock('../../../src/db/database', () => ({ db: { prepare: () => ({ get: () => undefined }) }, canAccessTrip: vi.fn() }));
|
||||
vi.mock('../../../src/nest/plugins/kill-switch', () => ({ pluginsEnabled }));
|
||||
|
||||
import { AtlasLayersController } from '../../../src/nest/plugins/atlas-layers.controller';
|
||||
import type { PluginRuntimeService } from '../../../src/nest/plugins/plugin-runtime.service';
|
||||
import { AtlasLayersController } from '../../../src/nest/plugins/contributions/atlas-layers.controller';
|
||||
import type { PluginHooks } from '../../../src/nest/plugins/plugin-hooks.service';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const req = (id?: number) => ({ user: id === undefined ? undefined : { id } }) as any;
|
||||
function controller(invoke: (id: string) => unknown, providers = ['p1']) {
|
||||
const runtime = {
|
||||
providersOf: vi.fn(() => providers),
|
||||
invokeHook: vi.fn(async (id: string) => invoke(id)),
|
||||
} as unknown as PluginRuntimeService;
|
||||
atlasLayers: vi.fn(async (id: string) => invoke(id)),
|
||||
} as unknown as PluginHooks;
|
||||
return { c: new AtlasLayersController(runtime), runtime };
|
||||
}
|
||||
const layer = (over: Record<string, unknown> = {}) => ({ id: 'l1', countries: [{ code: 'FR' }], ...over });
|
||||
@@ -53,7 +53,7 @@ describe('AtlasLayersController', () => {
|
||||
countries: [{ code: 'FR', tone: 'success', label: 'Paris trip' }],
|
||||
}]);
|
||||
// user-scoped: empty args, the acting user is bound host-side
|
||||
expect(runtime.invokeHook).toHaveBeenCalledWith('p1', 'atlasLayerProvider', 'getLayers', [], 5, 5000);
|
||||
expect(runtime.atlasLayers).toHaveBeenCalledWith('p1', 5);
|
||||
});
|
||||
|
||||
it('uppercase-coerces codes, drops anything that is not ISO alpha-2, defaults a bad tone', async () => {
|
||||
|
||||
Reference in New Issue
Block a user