Figure 15-4. Debugging in the JavaScript console
So let’s now just pile in and get the test to pass:
accounts/static/accounts.js (ch15l029).
var
initialize
=
function
(
navigator
) {
navigator
.
id
.
request
();
};
That gets the tests to pass, but it’s not quite the implementation we want. We’re calling
navigator.id.request
always, instead of only on click. We’ll need to adjust our tests.
1 assertions of 1 passed, 0 failed.
1. initialize binds sign in button to navigator.id.request (0, 1, 1)
Before we do, let’s just have a play around to see if we really understand what’s going
on. What happens if we do this?
accounts/static/accounts.js (ch15l029-1).
var
initialize
=
function
(
navigator
) {
navigator
.
id
.
request
();
navigator
.
id
.
doSomethingElse
();
};
We get:
262
|
Chapter 15: User Authentication, Integrating Third-Party Plugins, and Mocking with JavaScript