forked from Yara724/api
Toggle External API
This commit is contained in:
31
src/system-settings/system-settings.service.spec.ts
Normal file
31
src/system-settings/system-settings.service.spec.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { SystemSettingsService } from "./system-settings.service";
|
||||
|
||||
describe("SystemSettingsService", () => {
|
||||
const db = {
|
||||
findGlobal: jest.fn(),
|
||||
upsertGlobal: jest.fn(),
|
||||
};
|
||||
|
||||
let service: SystemSettingsService;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
service = new SystemSettingsService(db as any);
|
||||
});
|
||||
|
||||
it("defaults to mock when DB field is false", async () => {
|
||||
db.findGlobal.mockResolvedValue({
|
||||
key: "global",
|
||||
externalApis: { sandHubUseLiveApi: false },
|
||||
});
|
||||
await expect(service.isSandHubLiveEnabled()).resolves.toBe(false);
|
||||
});
|
||||
|
||||
it("uses live mode when DB field is true", async () => {
|
||||
db.findGlobal.mockResolvedValue({
|
||||
key: "global",
|
||||
externalApis: { sandHubUseLiveApi: true },
|
||||
});
|
||||
await expect(service.isSandHubLiveEnabled()).resolves.toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user