@thoughtspot/visual-embed-sdk
Version:
ThoughtSpot Embed SDK
29 lines • 1.89 kB
JavaScript
import { buildSpotterVizAppInitData } from './spotter-viz-utils';
describe('buildSpotterVizAppInitData', () => {
const base = { type: 'APP_INIT' };
it('returns initData unchanged when spotterViz is not provided', () => {
const result = buildSpotterVizAppInitData(base, {});
expect(result).toBe(base);
});
it('nests spotterViz under embedParams.spotterVizConfig', () => {
var _a;
const spotterViz = { brandName: 'MyBrand', description: 'Desc', inputChatPlaceholder: 'Ask...' };
const result = buildSpotterVizAppInitData(base, { spotterViz });
expect((_a = result.embedParams) === null || _a === void 0 ? void 0 : _a.spotterVizConfig).toEqual(spotterViz);
});
it('passes brandHeadline through spotterVizConfig', () => {
var _a, _b;
const spotterViz = { brandName: 'MyBrand', brandHeadline: "Hi, there! I'm" };
const result = buildSpotterVizAppInitData(base, { spotterViz });
expect((_b = (_a = result.embedParams) === null || _a === void 0 ? void 0 : _a.spotterVizConfig) === null || _b === void 0 ? void 0 : _b.brandHeadline).toBe("Hi, there! I'm");
});
it('preserves existing embedParams when adding spotterVizConfig', () => {
var _a, _b, _c;
const existing = { ...base, embedParams: { spotterSidebarConfig: { enablePastConversationsSidebar: true } } };
const spotterViz = { brandName: 'MyBrand' };
const result = buildSpotterVizAppInitData(existing, { spotterViz });
expect((_a = result.embedParams) === null || _a === void 0 ? void 0 : _a.spotterVizConfig).toEqual(spotterViz);
expect((_c = (_b = result.embedParams) === null || _b === void 0 ? void 0 : _b.spotterSidebarConfig) === null || _c === void 0 ? void 0 : _c.enablePastConversationsSidebar).toBe(true);
});
});
//# sourceMappingURL=spotter-viz-utils.spec.js.map