Skip to content

Commit

Permalink
Add unittest about propagating configuraitonMode from SHELL_EVENTS.Ve…
Browse files Browse the repository at this point in the history
…rsion1.OUTLET.REQUEST_CONTEXT
  • Loading branch information
Sébastien Barbier committed Apr 17, 2020
1 parent 9ca492d commit 717bb1a
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions src/tests/Outlets.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,4 +270,59 @@ describe('Outlets', () => {
expect(postMessageOutlet.called).toBe(false);
});



it('should not propagate SHELL_EVENTS.Version1.OUTLET.REQUEST_CONTEXT isConfigurationMode changes', () => {
sdk = ShellSdk.init(sdkTarget, sdkOrigin, windowMock);

let value: any;

// postMessage catch messages send to outlets
const postMessage = sinon.spy();
sdk.registerOutlet({
contentWindow: {
postMessage
} as any as Window
} as any as HTMLIFrameElement);

windowMockCallback({
data: {
type: SHELL_EVENTS.Version1.OUTLET.REQUEST_CONTEXT,
value: {
isConfigurationMode: true,
target: ''
}
}
});

expect(postMessage.called).toBe(false);
postMessage.resetHistory();

windowMockCallback({
data: {
type: SHELL_EVENTS.Version1.OUTLET.REQUEST_CONTEXT,
value: {
isConfigurationMode: true
}
}
});

expect(postMessage.called).toBe(true);
postMessage.resetHistory();

windowMockCallback({
data: {
type: SHELL_EVENTS.Version1.OUTLET.REQUEST_CONTEXT,
value: {
isConfigurationMode: true,
plugin: {}
}
}
});

expect(postMessage.called).toBe(false);


});

});

0 comments on commit 717bb1a

Please sign in to comment.