File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ import * as processTrigger from '../utils/processTrigger' ;
2+ import { reloadIframe } from './base' ;
3+
4+ describe ( 'reloadIframe (global method)' , ( ) => {
5+ test ( 'should call reload with the provided iframe' , ( ) => {
6+ // Arrange
7+ const iFrameElement = document . createElement ( 'iframe' ) ;
8+ const html = '<body>Foo</body>' ;
9+ iFrameElement . src = `data:text/html;charset=utf-8,${ encodeURI ( html ) } ` ;
10+ const spyReload = jest . spyOn ( processTrigger , 'reload' ) ;
11+
12+ // Act
13+ reloadIframe ( iFrameElement ) ;
14+
15+ // Assert
16+ expect ( spyReload ) . toHaveBeenCalledWith ( iFrameElement ) ;
17+ } ) ;
18+ } ) ;
19+
120/* eslint-disable no-console */
221/* eslint-disable @typescript-eslint/no-shadow */
322import EventEmitter from 'eventemitter3' ;
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ import { uploadMixpanelEvent, MIXPANEL_EVENT } from '../mixpanel-service';
3535import { getEmbedConfig , setEmbedConfig } from './embedConfig' ;
3636import { getQueryParamString , getValueFromWindow , storeValueInWindow } from '../utils' ;
3737import { resetAllCachedServices } from '../utils/resetServices' ;
38+ import { reload } from '../utils/processTrigger' ;
3839
3940const CONFIG_DEFAULTS : Partial < EmbedConfig > = {
4041 loginFailedMessage : 'Not logged in' ,
@@ -459,3 +460,17 @@ export function reset(): void {
459460 setAuthEE ( null ) ;
460461 authPromise = null ;
461462}
463+
464+ /**
465+ * Reloads the ThoughtSpot iframe.
466+ * @param iFrame
467+ * @group Global methods
468+ * @version SDK: 1.43.1
469+ */
470+ export const reloadIframe = ( iFrame : HTMLIFrameElement ) => {
471+ if ( ! iFrame ) {
472+ logger . warn ( 'reloadIframe called with no iFrame element.' ) ;
473+ return ;
474+ }
475+ reload ( iFrame ) ;
476+ } ;
You can’t perform that action at this time.
0 commit comments