Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
glena committed Feb 3, 2017
1 parent b735192 commit 2ca0c6a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 11 deletions.
12 changes: 6 additions & 6 deletions example/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@

webAuth.redirect.loginWithCredentials({
connection: 'tests',
username: $('.login-username').val(),
password: $('.login-password').val(),
scope: $('.login-scope').val(),
responseType: $('.login-response-type').val()
username: $('#login-username').val(),
password: $('#login-password').val(),
scope: $('#login-scope').val(),
responseType: $('#login-response-type').val()
}, function (err) {
$('#err').html(JSON.stringify(err));
});
Expand All @@ -44,8 +44,8 @@
e.preventDefault();

webAuth.authorize({
scope: $('.login-scope').val(),
responseType: $('.login-response-type').val()
scope: $('#login-scope').val(),
responseType: $('#login-response-type').val()
});
});

Expand Down
41 changes: 37 additions & 4 deletions integration/redirect_authorize.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,19 @@ describe('redirect authorize', function () {
driver.wait(until.elementLocated(By.id('parsed')), 10000);

driver.findElement(By.id('err')).getText().then(function(value) {
console.log('ERR:', value);
expect(value).to.equal('');
});

driver.findElement(By.id('result')).getText().then(function(value) {
console.log('RESULT:', value);
expect(value).to.not.equal('');

var response = JSON.parse(value);

expect(response.accessToken).to.be.ok();
expect(response.idToken).to.not.be.ok();
expect(response.tokenType).to.be.ok();
expect(response.expiresIn).to.be.ok();
});

return driver.quit();
Expand All @@ -43,10 +51,11 @@ describe('redirect authorize', function () {
driver.findElement(By.id('email')).sendKeys('johnfoo@gmail.com');
driver.findElement(By.id('password')).sendKeys('1234');
driver.findElement(By.id('upLogin')).click();
driver.wait(until.elementLocated(By.id('parsed')), 10000);
driver.wait(until.elementLocated(By.id('loaded')), 10000);

driver.getTitle().then(function(url) {
expect(value).to.contain('code=');
driver.getCurrentUrl().then(function(url) {
console.log('RESULT URL:', url);
expect(url).to.contain('code=');
});

return driver.quit();
Expand All @@ -71,7 +80,15 @@ describe('redirect authorize', function () {
});

driver.findElement(By.id('result')).getText().then(function(value) {
console.log('RESULT:', value);
expect(value).to.not.equal('');

var response = JSON.parse(value);

expect(response.accessToken).to.be.ok();
expect(response.idToken).to.be.ok();
expect(response.tokenType).to.be.ok();
expect(response.expiresIn).to.be.ok();
});

return driver.quit();
Expand All @@ -95,7 +112,15 @@ describe('redirect authorize', function () {
});

driver.findElement(By.id('result')).getText().then(function(value) {
console.log('RESULT:', value);
expect(value).to.not.equal('');

var response = JSON.parse(value);

expect(response.accessToken).to.not.be.ok();
expect(response.idToken).to.be.ok();
expect(response.tokenType).to.not.be.ok();
expect(response.expiresIn).to.not.be.ok();
});

return driver.quit();
Expand All @@ -119,7 +144,15 @@ describe('redirect authorize', function () {
});

driver.findElement(By.id('result')).getText().then(function(value) {
console.log('RESULT:', value);
expect(value).to.not.equal('');

var response = JSON.parse(value);

expect(response.accessToken).to.be.ok();
expect(response.idToken).to.be.ok();
expect(response.tokenType).to.be.ok();
expect(response.expiresIn).to.be.ok();
});

return driver.quit();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"start": "gulp dev",
"build": "gulp build",
"test": "mocha test/**/*.test.js",
"test:integration": "mocha-parallel-tests --max-parallel 8 integration/**/*.test.js",
"test:integration": "mocha-parallel-tests --max-parallel 2 integration/**/*.test.js",
"test:watch": "mocha --watch -R min test/**/*.test.js",
"test:coverage": "istanbul cover _mocha -R test/**/*",
"test:ci": "istanbul cover _mocha --report lcovonly -R test/**/*; codecov",
Expand Down

0 comments on commit 2ca0c6a

Please sign in to comment.