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

refactor(js-client): convert fxa-js-client and its tests to commonjs #2039

Merged
merged 1 commit into from
Aug 13, 2019

Conversation

vladikoff
Copy link
Contributor

  • changes client structure
  • moves to mocha

Fixes #1857

@shane-tomlinson
Copy link
Contributor

🎆 🎆 🎆 🎆 🎆 🎆 🎆 🎆 🎆 🎆 🎆 🎆 🎆 🎆 🎆 🎆 🎆 🎆 🎆 🎆 🎆 🎆

Copy link
Contributor

@shane-tomlinson shane-tomlinson left a comment

Choose a reason for hiding this comment

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

Sorry for the possible premature review, I'm just excited to see this! Overall looks great, there are a few questions but nothing that looks even remotely blockerish except for the failing tests.

packages/fxa-js-client/tests/addons/environment.js Outdated Show resolved Hide resolved
@@ -1,9 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
Copy link
Contributor

Choose a reason for hiding this comment

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

Amazing.

@@ -51,11 +52,12 @@
"grunt-open": "0.2.4",
"grunt-webpack": "3.0.2",
"http-proxy": "1.11.1",
"intern-geezer": "2.2.3",
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

"test": "grunt test",
"test-local": "intern-client config=tests/intern auth_server=LOCAL",
"test": "mocha tests/lib --reporter dot",
"test-local": "AUTH_SERVER_URL=http://127.0.0.1:9000 mocha tests/lib --reporter dot",
Copy link
Contributor

Choose a reason for hiding this comment

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

I get some failures running this command.

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 pass now

packages/fxa-js-client/tests/lib/oauth.js Outdated Show resolved Hide resolved
packages/fxa-js-client/tests/mocks/request.js Outdated Show resolved Hide resolved
@vbudhram
Copy link
Contributor

vbudhram commented Aug 5, 2019

@vladikoff Do you have train you are targeting this for and an estimate?

Copy link
Contributor Author

@vladikoff vladikoff left a comment

Choose a reason for hiding this comment

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

@shane-tomlinson this should be good to go now

ErrorMocks.signInBlocked
);
})
.then(assert.notOk, function(error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is curious. assert.notOk is not supposed to be executed is it, so did it need to change? Are the assertions below still being executed?

Copy link
Contributor

Choose a reason for hiding this comment

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

From the documentation of isNotOk (which according to the source is just an alias for notOk, assert.notOk will only fail of the value passed to it is falsy. That means @philbooth is right, the error handler is not guaranteed to be called here. Any time assert.notOk is used as the success when we do not expect it to be called should be an assert.fail.

Copy link
Contributor

@shane-tomlinson shane-tomlinson left a comment

Choose a reason for hiding this comment

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

I'm very excited for this! The comment @philbooth made about assert.notOk being used for the success handler is spot on. If we do not expect the success handler to be called, those need to be assert.fail or else the error handler is not guaranteed to run.

service: 'sync',
redirectTo: 'https://sync.127.0.0.1/after_reset',
resume: 'resumejwt',
style: 'trailhead',
Copy link
Contributor

Choose a reason for hiding this comment

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

All emails use "trailhead" style now, 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.

it seems so!

assert.ok(resp);
},
error => {
console.log(error);
Copy link
Contributor

Choose a reason for hiding this comment

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

console.log!

ErrorMocks.signInBlocked
);
})
.then(assert.notOk, function(error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

From the documentation of isNotOk (which according to the source is just an alias for notOk, assert.notOk will only fail of the value passed to it is falsy. That means @philbooth is right, the error handler is not guaranteed to be called here. Any time assert.notOk is used as the success when we do not expect it to be called should be an assert.fail.

* changes client structure
* moves to mocha

Fixes #1857
@vladikoff
Copy link
Contributor Author

@shane-tomlinson updated!

Copy link
Contributor

@shane-tomlinson shane-tomlinson left a comment

Choose a reason for hiding this comment

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

R...... +

Thanks for the iterations @vladikoff, this is a great change.

@vladikoff vladikoff merged commit 47ff101 into master Aug 13, 2019
@vladikoff vladikoff deleted the mocha-js-client branch August 13, 2019 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[fxa-js-client] convert js-client unit tests to mocha
4 participants