UNPKG

@thoughtspot/visual-embed-sdk

Version:
31 lines 2.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const spotter_viz_utils_1 = require("./spotter-viz-utils"); describe('buildSpotterVizAppInitData', () => { const base = { type: 'APP_INIT' }; it('returns initData unchanged when spotterViz is not provided', () => { const result = (0, spotter_viz_utils_1.buildSpotterVizAppInitData)(base, {}); expect(result).toBe(base); }); it('nests spotterViz under embedParams.spotterVizConfig', () => { var _a; const spotterViz = { brandName: 'MyBrand', description: 'Desc', inputChatPlaceholder: 'Ask...' }; const result = (0, spotter_viz_utils_1.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 = (0, spotter_viz_utils_1.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 = (0, spotter_viz_utils_1.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