Skip to content
This repository was archived by the owner on Oct 2, 2021. It is now read-only.

Add a unit test for the overriding behavior of sendLoadedSourceEvent()#271

Merged
roblourens merged 1 commit intomicrosoft:masterfrom
changsi-an:master
Jan 22, 2018
Merged

Add a unit test for the overriding behavior of sendLoadedSourceEvent()#271
roblourens merged 1 commit intomicrosoft:masterfrom
changsi-an:master

Conversation

@changsi-an
Copy link
Contributor

@changsi-an changsi-an commented Jan 22, 2018

Added 1 more test.

@changsi-an
Copy link
Contributor Author

@digeff PTAL

const loadedSourceEventReason: LoadedSourceEventReason = 'changed';
sendEventHandler = (event) => {
assert.equal('loadedSource', event.event);
assert.notEqual(null, event.body);
Copy link
Contributor

Choose a reason for hiding this comment

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

Would the test catch more potential issues if we tested the contents of all the members of the event argument?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we keep the tests atomic and follow the one-thing-at-a-time principle? Or otherwise, when the product code changes, we might have to update all the tests, which is tedious and does not gain us anything.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally the test should only fail when the contract/interface changes. If we change the implementation while maintaining the original contract/interface then the test shouldn't fail nor need updating.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved offline. @digeff and I both agree on this change now.

assert.equal('loadedSource', event.event);
assert.notEqual(null, event.body);
assert.equal(loadedSourceEventReason, event.body.reason);
done();
Copy link
Contributor

Choose a reason for hiding this comment

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

How will done be called if the test fails?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will timeout and show as a timeout failure.

Copy link
Contributor

Choose a reason for hiding this comment

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

It'd be great if we could show the actual failure rather than a timeout.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to return the promise directly instead of using done method.

Copy link
Member

@roblourens roblourens left a comment

Choose a reason for hiding this comment

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

Thanks!

@roblourens roblourens merged commit 0b886b6 into microsoft:master Jan 22, 2018
@roblourens roblourens added this to the January 2018 milestone Feb 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants