mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-23 21:33:19 +00:00
8b9de04960
With Tours off for the instance, a trip that switched it on opened the wanderer import, but Settings hid the connection and the watch cron never ran. The addon feed now tells each user whether wanderer applies to them, and the watch looks for every user who has Tours on somewhere; the others only take their turn.
29 lines
1.1 KiB
TypeScript
29 lines
1.1 KiB
TypeScript
import { AddonsController } from '../../../src/nest/addons/addons.controller';
|
|
import type { AddonsService } from '../../../src/nest/addons/addons.service';
|
|
import type { User } from '../../../src/types';
|
|
|
|
import { describe, it, expect, vi } from 'vitest';
|
|
|
|
function makeService(overrides: Partial<AddonsService> = {}): AddonsService {
|
|
return {
|
|
list: vi.fn().mockReturnValue({ collabFeatures: {}, bagTracking: false, addons: [] }),
|
|
...overrides,
|
|
} as unknown as AddonsService;
|
|
}
|
|
|
|
describe('AddonsController (parity with the legacy GET /api/addons route)', () => {
|
|
it('GET / delegates straight to the service and returns its feed', async () => {
|
|
const feed = {
|
|
collabFeatures: { comments: true },
|
|
bagTracking: true,
|
|
addons: [{ id: 'atlas', name: 'Atlas', type: 'page', icon: 'globe', enabled: true }],
|
|
};
|
|
const list = vi.fn().mockReturnValue(feed);
|
|
const svc = makeService({ list } as Partial<AddonsService>);
|
|
|
|
expect(await new AddonsController(svc).list({ id: 4 } as User)).toBe(feed);
|
|
expect(list).toHaveBeenCalledTimes(1);
|
|
expect(list).toHaveBeenCalledWith(4);
|
|
});
|
|
});
|