UNPKG

@thoughtspot/visual-embed-sdk

Version:
37 lines 1.51 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const index_1 = require("../index"); const test_utils_1 = require("../test/test-utils"); const authInstance = tslib_1.__importStar(require("../auth")); describe('Trigger', () => { beforeEach(() => { document.body.innerHTML = (0, test_utils_1.getDocumentBody)(); jest.spyOn(authInstance, 'postLoginService').mockResolvedValue(true); }); test('should trigger the event', async (done) => { (0, index_1.init)({ thoughtSpotHost: 'https://tshost', authType: index_1.AuthType.None, }); const lb = new index_1.LiveboardEmbed((0, test_utils_1.getRootEl)(), { frameParams: { width: '100%', height: '100%', }, liveboardId: '123', }); const val = await lb.render(); const iframe = (0, test_utils_1.getIFrameEl)(); jest.spyOn(iframe.contentWindow, 'postMessage'); (0, test_utils_1.executeAfterWait)(() => { lb.trigger(index_1.HostEvent.DownloadAsCsv, { vizId: 'testId' }); expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: index_1.HostEvent.DownloadAsCsv, data: { vizId: 'testId' }, }), 'https://tshost', expect.anything()); done(); }); }); }); //# sourceMappingURL=ts-embed-trigger.spec.js.map