-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssistEnabledTest.test.ts
More file actions
52 lines (45 loc) · 2.15 KB
/
AssistEnabledTest.test.ts
File metadata and controls
52 lines (45 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { CxWrapper } from '../main/wrapper/CxWrapper';
import { BaseTest } from './BaseTest';
import { ExecutionService } from '../main/wrapper/ExecutionService';
import { CxConstants } from '../main/wrapper/CxConstants';
describe('cxOneAssistEnabled tenant setting', () => {
const baseConfig = new BaseTest();
afterEach(() => {
jest.restoreAllMocks();
});
it('returns true when assist key value is true (lowercase)', async () => {
jest.spyOn(ExecutionService.prototype, 'executeMapTenantOutputCommands')
.mockResolvedValue(new Map([[CxConstants.ASSIST_KEY, 'true']]));
const wrapper = new CxWrapper(baseConfig);
const enabled = await wrapper.cxOneAssistEnabled();
expect(enabled).toBe(true);
});
it('returns true when assist key value is TRUE (uppercase)', async () => {
jest.spyOn(ExecutionService.prototype, 'executeMapTenantOutputCommands')
.mockResolvedValue(new Map([[CxConstants.ASSIST_KEY, 'TRUE']]));
const wrapper = new CxWrapper(baseConfig);
const enabled = await wrapper.cxOneAssistEnabled();
expect(enabled).toBe(true);
});
it('returns false when assist key value is false', async () => {
jest.spyOn(ExecutionService.prototype, 'executeMapTenantOutputCommands')
.mockResolvedValue(new Map([[CxConstants.ASSIST_KEY, 'false']]));
const wrapper = new CxWrapper(baseConfig);
const enabled = await wrapper.cxOneAssistEnabled();
expect(enabled).toBe(false);
});
it('returns false when assist key is missing', async () => {
jest.spyOn(ExecutionService.prototype, 'executeMapTenantOutputCommands')
.mockResolvedValue(new Map([[CxConstants.IDE_SCANS_KEY, 'true']]));
const wrapper = new CxWrapper(baseConfig);
const enabled = await wrapper.cxOneAssistEnabled();
expect(enabled).toBe(false);
});
it('trims whitespace around key/value before evaluating', async () => {
jest.spyOn(ExecutionService.prototype, 'executeMapTenantOutputCommands')
.mockResolvedValue(new Map([[` ${CxConstants.ASSIST_KEY} `, ' true ']]));
const wrapper = new CxWrapper(baseConfig);
const enabled = await wrapper.cxOneAssistEnabled();
expect(enabled).toBe(true);
});
});