Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Handle errors in test-amp-user-notification.js #15659

Merged
merged 1 commit into from
May 30, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ describes.realWin('amp-user-notification', {
'layout': 'nodisplay',
});
const impl = el.implementation_;
expect(impl.buildCallback.bind(impl)).to.throw(/should have an id/);
allowConsoleError(() => {
expect(impl.buildCallback.bind(impl)).to.throw(/should have an id/);
});
});

it('should NOT require `data-show-if-href`', () => {
Expand Down Expand Up @@ -302,6 +304,8 @@ describes.realWin('amp-user-notification', {
const showEndpointStub = sandbox.stub(impl, 'getShowEndpoint_')
.returns(Promise.resolve({showNotification: true}));

expectAsyncConsoleError(
'[amp-user-notification] Failed to read storage intentional');
return impl.shouldShow().then(shouldShow => {
expect(shouldShow).to.equal(true);
expect(cidStub).to.be.calledOnce;
Expand All @@ -320,6 +324,8 @@ describes.realWin('amp-user-notification', {
.withExactArgs('amp-user-notification:n1')
.returns(Promise.reject('intentional'))
.once();
expectAsyncConsoleError(
'[amp-user-notification] Failed to read storage intentional');
return impl.shouldShow().then(shouldShow => {
expect(shouldShow).to.equal(true);
storageMock.verify();
Expand Down Expand Up @@ -652,6 +658,8 @@ describes.realWin('amp-user-notification', {
impl.getCidService_ = () => { return Promise.resolve(cidMock); };
dismissSpy = sandbox.spy(impl, 'dismiss');

expectAsyncConsoleError(
'[amp-user-notification] Failed to opt out of Cid failed');
return impl.optoutOfCid_().then(() => {
expect(dismissSpy).to.be.calledWithExactly(true);
expect(optOutOfCidStub).to.be.calledOnce;
Expand Down