Skip to content

Commit 748031c

Browse files
added test cases
1 parent d093b39 commit 748031c

File tree

2 files changed

+105
-0
lines changed

2 files changed

+105
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { CxWrapper } from '../main/wrapper/CxWrapper';
2+
import { BaseTest } from './BaseTest';
3+
import { ExecutionService } from '../main/wrapper/ExecutionService';
4+
import { CxConstants } from '../main/wrapper/CxConstants';
5+
6+
describe('cxOneAssistEnabled tenant setting', () => {
7+
const baseConfig = new BaseTest();
8+
9+
afterEach(() => {
10+
jest.restoreAllMocks();
11+
});
12+
13+
it('returns true when assist key value is true (lowercase)', async () => {
14+
jest.spyOn(ExecutionService.prototype, 'executeMapTenantOutputCommands')
15+
.mockResolvedValue(new Map([[CxConstants.ASSIST_KEY, 'true']]));
16+
const wrapper = new CxWrapper(baseConfig);
17+
const enabled = await wrapper.cxOneAssistEnabled();
18+
expect(enabled).toBe(true);
19+
});
20+
21+
it('returns true when assist key value is TRUE (uppercase)', async () => {
22+
jest.spyOn(ExecutionService.prototype, 'executeMapTenantOutputCommands')
23+
.mockResolvedValue(new Map([[CxConstants.ASSIST_KEY, 'TRUE']]));
24+
const wrapper = new CxWrapper(baseConfig);
25+
const enabled = await wrapper.cxOneAssistEnabled();
26+
expect(enabled).toBe(true);
27+
});
28+
29+
it('returns false when assist key value is false', async () => {
30+
jest.spyOn(ExecutionService.prototype, 'executeMapTenantOutputCommands')
31+
.mockResolvedValue(new Map([[CxConstants.ASSIST_KEY, 'false']]));
32+
const wrapper = new CxWrapper(baseConfig);
33+
const enabled = await wrapper.cxOneAssistEnabled();
34+
expect(enabled).toBe(false);
35+
});
36+
37+
it('returns false when assist key is missing', async () => {
38+
jest.spyOn(ExecutionService.prototype, 'executeMapTenantOutputCommands')
39+
.mockResolvedValue(new Map([[CxConstants.IDE_SCANS_KEY, 'true']]));
40+
const wrapper = new CxWrapper(baseConfig);
41+
const enabled = await wrapper.cxOneAssistEnabled();
42+
expect(enabled).toBe(false);
43+
});
44+
45+
it('trims whitespace around key/value before evaluating', async () => {
46+
jest.spyOn(ExecutionService.prototype, 'executeMapTenantOutputCommands')
47+
.mockResolvedValue(new Map([[` ${CxConstants.ASSIST_KEY} `, ' true ']]));
48+
const wrapper = new CxWrapper(baseConfig);
49+
const enabled = await wrapper.cxOneAssistEnabled();
50+
expect(enabled).toBe(true);
51+
});
52+
});
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { CxWrapper } from '../main/wrapper/CxWrapper';
2+
import { BaseTest } from './BaseTest';
3+
import { ExecutionService } from '../main/wrapper/ExecutionService';
4+
import { CxConstants } from '../main/wrapper/CxConstants';
5+
6+
describe('standaloneEnabled tenant setting', () => {
7+
const baseConfig = new BaseTest();
8+
9+
afterEach(() => {
10+
jest.restoreAllMocks();
11+
});
12+
13+
it('returns true when standalone tenant flag is true (lowercase)', async () => {
14+
jest.spyOn(ExecutionService.prototype, 'executeMapTenantOutputCommands')
15+
.mockResolvedValue(new Map([[CxConstants.STANDALONE_KEY, 'true']]));
16+
const wrapper = new CxWrapper(baseConfig);
17+
const enabled = await wrapper.standaloneEnabled();
18+
expect(enabled).toBe(true);
19+
});
20+
21+
it('returns true when standalone tenant flag is TRUE (uppercase)', async () => {
22+
jest.spyOn(ExecutionService.prototype, 'executeMapTenantOutputCommands')
23+
.mockResolvedValue(new Map([[CxConstants.STANDALONE_KEY, 'TRUE']]));
24+
const wrapper = new CxWrapper(baseConfig);
25+
const enabled = await wrapper.standaloneEnabled();
26+
expect(enabled).toBe(true);
27+
});
28+
29+
it('returns false when standalone tenant flag is false', async () => {
30+
jest.spyOn(ExecutionService.prototype, 'executeMapTenantOutputCommands')
31+
.mockResolvedValue(new Map([[CxConstants.STANDALONE_KEY, 'false']]));
32+
const wrapper = new CxWrapper(baseConfig);
33+
const enabled = await wrapper.standaloneEnabled();
34+
expect(enabled).toBe(false);
35+
});
36+
37+
it('returns false when standalone tenant flag key is missing', async () => {
38+
jest.spyOn(ExecutionService.prototype, 'executeMapTenantOutputCommands')
39+
.mockResolvedValue(new Map([[CxConstants.IDE_SCANS_KEY, 'true']]));
40+
const wrapper = new CxWrapper(baseConfig);
41+
const enabled = await wrapper.standaloneEnabled();
42+
expect(enabled).toBe(false);
43+
});
44+
45+
it('trims whitespace around key and value before evaluating', async () => {
46+
// Simulate raw output map entries with leading/trailing spaces
47+
jest.spyOn(ExecutionService.prototype, 'executeMapTenantOutputCommands')
48+
.mockResolvedValue(new Map([[` ${CxConstants.STANDALONE_KEY} `, ' true ']]));
49+
const wrapper = new CxWrapper(baseConfig);
50+
const enabled = await wrapper.standaloneEnabled();
51+
expect(enabled).toBe(true);
52+
});
53+
});

0 commit comments

Comments
 (0)