@thoughtspot/visual-embed-sdk
Version:
ThoughtSpot Embed SDK
74 lines • 3.29 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const embedConfig_1 = require("./embedConfig");
const utils_1 = require("../utils");
describe('embedConfig', () => {
beforeEach(() => {
// Ensure the SDK window namespace exists before resetting individual keys
(0, utils_1.storeValueInWindow)('embedConfig', undefined);
(0, utils_1.resetValueFromWindow)('embedConfig');
});
describe('getEmbedConfig', () => {
test('returns empty object when no config has been set', () => {
expect((0, embedConfig_1.getEmbedConfig)()).toEqual({});
});
test('returns the config that was previously set', () => {
const config = {
thoughtSpotHost: 'https://myhost.thoughtspot.com',
authType: 'None',
};
(0, embedConfig_1.setEmbedConfig)(config);
expect((0, embedConfig_1.getEmbedConfig)()).toEqual(config);
});
test('returns the full config object including nested properties', () => {
const config = {
thoughtSpotHost: 'https://myhost.thoughtspot.com',
authType: 'None',
customizations: {
style: {
customCSS: {
variables: { '--ts-var-root-background': '#fff' },
},
},
},
};
(0, embedConfig_1.setEmbedConfig)(config);
expect((0, embedConfig_1.getEmbedConfig)()).toEqual(config);
});
});
describe('setEmbedConfig', () => {
test('stores the config and returns it', () => {
const config = {
thoughtSpotHost: 'https://myhost.thoughtspot.com',
authType: 'None',
};
const result = (0, embedConfig_1.setEmbedConfig)(config);
expect(result).toEqual(config);
});
test('getEmbedConfig reflects the config after setEmbedConfig', () => {
const config = {
thoughtSpotHost: 'https://updated.thoughtspot.com',
authType: 'TrustedAuthToken',
};
(0, embedConfig_1.setEmbedConfig)(config);
expect((0, embedConfig_1.getEmbedConfig)()).toEqual(config);
});
test('overwrites a previously stored config', () => {
const first = { thoughtSpotHost: 'https://first.com', authType: 'None' };
const second = { thoughtSpotHost: 'https://second.com', authType: 'TrustedAuthToken' };
(0, embedConfig_1.setEmbedConfig)(first);
(0, embedConfig_1.setEmbedConfig)(second);
expect((0, embedConfig_1.getEmbedConfig)()).toEqual(second);
});
test('handles config with disableFullscreenPresentation flag', () => {
const config = {
thoughtSpotHost: 'https://myhost.thoughtspot.com',
authType: 'None',
disableFullscreenPresentation: true,
};
(0, embedConfig_1.setEmbedConfig)(config);
expect((0, embedConfig_1.getEmbedConfig)().disableFullscreenPresentation).toBe(true);
});
});
});
//# sourceMappingURL=embedConfig.spec.js.map