|
| 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