2022-03-03 09:35:26 +00:00
|
|
|
import * as manager from '../../modules/manager';
|
|
|
|
import * as platform from '../../modules/platform';
|
2021-08-15 05:25:30 +00:00
|
|
|
import { getOptions } from '.';
|
2020-03-07 10:27:10 +00:00
|
|
|
|
2022-03-03 09:35:26 +00:00
|
|
|
jest.unmock('../../modules/platform');
|
2020-03-07 10:27:10 +00:00
|
|
|
|
2021-08-18 05:46:56 +00:00
|
|
|
describe('config/options/index', () => {
|
2020-03-07 10:27:10 +00:00
|
|
|
it('test manager should have no defaultConfig', () => {
|
2022-03-03 09:35:26 +00:00
|
|
|
jest.mock('../../modules/manager', () => ({
|
2021-11-03 05:48:10 +00:00
|
|
|
getManagers: jest.fn(() => new Map().set('testManager', {})),
|
|
|
|
}));
|
|
|
|
|
2020-03-07 10:27:10 +00:00
|
|
|
const opts = getOptions();
|
2020-04-12 16:09:36 +00:00
|
|
|
expect(opts.filter((o) => o.name === 'testManager')).toEqual([]);
|
2020-03-07 10:27:10 +00:00
|
|
|
});
|
2021-11-03 05:48:10 +00:00
|
|
|
|
|
|
|
it('supportedManagers should have valid names', () => {
|
2022-03-03 09:35:26 +00:00
|
|
|
jest.unmock('../../modules/manager');
|
2021-11-03 05:48:10 +00:00
|
|
|
const opts = getOptions();
|
|
|
|
const managerList = Array.from(manager.getManagers().keys());
|
|
|
|
|
|
|
|
opts
|
|
|
|
.filter((option) => option.supportedManagers)
|
|
|
|
.forEach((option) => {
|
|
|
|
expect(option.supportedManagers).toBeNonEmptyArray();
|
2022-04-24 22:48:54 +00:00
|
|
|
for (const item of option.supportedManagers!) {
|
2021-11-03 05:48:10 +00:00
|
|
|
expect(managerList).toContain(item);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('supportedPlatforms should have valid names', () => {
|
2022-03-03 09:35:26 +00:00
|
|
|
jest.unmock('../../modules/platform');
|
2021-11-03 05:48:10 +00:00
|
|
|
const opts = getOptions();
|
|
|
|
const platformList = Array.from(platform.getPlatforms().keys());
|
|
|
|
|
|
|
|
opts
|
|
|
|
.filter((option) => option.supportedPlatforms)
|
|
|
|
.forEach((option) => {
|
|
|
|
expect(option.supportedPlatforms).toBeNonEmptyArray();
|
2022-04-24 22:48:54 +00:00
|
|
|
for (const item of option.supportedPlatforms!) {
|
2021-11-03 05:48:10 +00:00
|
|
|
expect(platformList).toContain(item);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2020-03-07 10:27:10 +00:00
|
|
|
});
|