jan/web/services/extensionService.test.ts
Louis 302b73ae73
test: add web helpers, services, utils tests (#3669)
* test: add web helpers tests

* fix: coverage report

* test: add more tests

* test: add more generated tests

* chore: add more tests

* test: add more tests
2024-09-20 14:24:51 +07:00

36 lines
1.2 KiB
TypeScript

import { extensionManager } from '@/extension/ExtensionManager';
import { ExtensionTypeEnum } from '@janhq/core';
import { isCoreExtensionInstalled } from './extensionService';
test('isCoreExtensionInstalled returns true when both extensions are installed', () => {
jest.spyOn(extensionManager, 'get').mockImplementation((type) => {
if (type === ExtensionTypeEnum.Conversational || type === ExtensionTypeEnum.Model) return {};
return undefined;
});
expect(isCoreExtensionInstalled()).toBe(true);
});
test('isCoreExtensionInstalled returns false when Model extension is not installed', () => {
jest.spyOn(extensionManager, 'get').mockImplementation((type) => {
if (type === ExtensionTypeEnum.Conversational) return {};
if (type === ExtensionTypeEnum.Model) return undefined;
return undefined;
});
expect(isCoreExtensionInstalled()).toBe(false);
});
test('isCoreExtensionInstalled returns false when Conversational extension is not installed', () => {
jest.spyOn(extensionManager, 'get').mockImplementation((type) => {
if (type === ExtensionTypeEnum.Conversational) return undefined;
if (type === ExtensionTypeEnum.Model) return {};
return undefined;
});
expect(isCoreExtensionInstalled()).toBe(false);
});