Skip to content

Commit

Permalink
added test (ampproject#9010)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshay authored and Eric Kenney committed May 3, 2017
1 parent 7b23932 commit 0299283
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,35 @@ describes.sandboxed('AmpViewerIntegration', {}, () => {
expect(resolveSpy).to.have.been.calledWith(JSON.stringify(data));
});

it('handleMessage_ should resolve with correct data', () => {
const data = 12345;

const event = {
source: window,
origin: viewerOrigin,
data: {
app: '__AMPHTML__',
data,
name: 'messageName',
requestid: 1,
rsvp: true,
type: 's',
},
};

const resolveSpy = sandbox.stub();
const rejectSpy = sandbox.stub();
const waitingForResponse = {'1': {
resolve: resolveSpy,
reject: rejectSpy,
}};

sandbox.stub(messaging, 'waitingForResponse_', waitingForResponse);
messaging.handleMessage_(event);

expect(resolveSpy).to.have.been.calledWith(data);
});

it('handleMessage_ should reject', () => {
const event = {
source: window,
Expand Down

0 comments on commit 0299283

Please sign in to comment.