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

Fix state leakage in test-amp-user-notification.js #10200

Merged
merged 3 commits into from Jun 29, 2017

Conversation

lannka
Copy link
Contributor

@lannka lannka commented Jun 29, 2017

Blocking #10074

@lannka lannka requested a review from dreamofabear June 29, 2017 22:27
@lannka lannka requested a review from zhouyx June 29, 2017 22:27
@lannka lannka mentioned this pull request Jun 29, 2017
@lannka lannka requested a review from aghassemi June 29, 2017 22:39
});

afterEach(() => {
if (storageMock) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We no longer verify with storageMock? I see we create storageMock in every test, but only call verify() in some of them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Added to all cases.

We can't do in afterEach because for some cases we have to wait a promise to resolve :-(

Also, somehow having assertion in afterEach causes Mocha to report incorrect total test number.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, somehow having assertion in afterEach causes Mocha to report incorrect total test number.

I get this one

We can't do in afterEach because for some cases we have to wait a promise to resolve :-(

But afterEach will be called after test promise resolved right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but then you need to return impl.storagePromise_ in each test, which isn't nice.

return impl.show().then(() => {
expect(el).to.have.class('amp-active');
expect(addToFixedLayerStub).to.be.calledOnce;
expect(addToFixedLayerStub.getCall(0).args[0]).to.equal(el);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what here and below? do we need verify() as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only needed when there is storageMock.expects

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool

@lannka lannka merged commit abdb14d into ampproject:master Jun 29, 2017
@lannka lannka deleted the notification-test-fix branch June 29, 2017 23:21
mrjoro pushed a commit to mrjoro/amphtml that referenced this pull request Jun 30, 2017
* describes

* Fix flaky test-amp-user-notification.js

* verify
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants