Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(933)

Unified Diff: remoting/webapp/crd/js/identity_unittest.js

Issue 1017613002: Migrate Remoting Webapp Unittests to use QUnit 2.0 syntax. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Migrate to assert Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/webapp/crd/js/host_table_entry_unittest.js ('k') | remoting/webapp/crd/js/l10n_unittest.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/crd/js/identity_unittest.js
diff --git a/remoting/webapp/crd/js/identity_unittest.js b/remoting/webapp/crd/js/identity_unittest.js
index 5bd9452c87974379b0495682306effcfd6574be8..3971e610c55ad362d8a55072a224ca95d71fbfce 100644
--- a/remoting/webapp/crd/js/identity_unittest.js
+++ b/remoting/webapp/crd/js/identity_unittest.js
@@ -16,22 +16,25 @@ var getAuthToken = null;
var identity = null;
/**
+ * @param {QUnit.Assert} assert
* @constructor
* @implements {remoting.Identity.ConsentDialog}
*/
-var MockConsent = function() {
+var MockConsent = function(assert) {
/** @type {boolean} */
this.grantConsent = true;
/** @type {Array<string> | undefined} */
this.scopes = undefined;
+ /** @private {QUnit.Assert} */
+ this.assert_ = assert;
};
MockConsent.prototype.show = function() {
// The consent dialog should only be shown if a previous call to getAuthToken
// with {interactive: false} failed, and it should occur before any call with
// {interactive: true}.
- ok(getAuthToken.calledOnce);
- ok(getAuthToken.calledWith({'interactive': false}));
+ this.assert_.ok(getAuthToken.calledOnce);
+ this.assert_.ok(getAuthToken.calledWith({'interactive': false}));
getAuthToken.reset();
if (this.grantConsent) {
@@ -40,28 +43,28 @@ MockConsent.prototype.show = function() {
return Promise.resolve();
};
-module('Identity', {
- setup: function() {
+QUnit.module('Identity', {
+ beforeEach: function(/** QUnit.Assert*/ assert) {
chromeMocks.identity.mock$clearToken();
chromeMocks.activate(['identity', 'runtime']);
- consentDialog = new MockConsent();
+ consentDialog = new MockConsent(assert);
promptForConsent = sinon.spy(consentDialog, 'show');
identity = new remoting.Identity(consentDialog);
getAuthToken = sinon.spy(chromeMocks.identity, 'getAuthToken');
},
- teardown: function() {
+ afterEach: function() {
chromeMocks.restore();
getAuthToken.restore();
}
});
-test('consent is requested only on first invocation', function() {
- ok(!promptForConsent.called);
+QUnit.test('consent is requested only on first invocation', function(assert) {
+ assert.ok(!promptForConsent.called);
return identity.getToken().then(
function(/** string */ token) {
- ok(promptForConsent.called);
- ok(getAuthToken.calledOnce);
- ok(getAuthToken.calledWith({'interactive': true}));
+ assert.ok(promptForConsent.called);
+ assert.ok(getAuthToken.calledOnce);
+ assert.ok(getAuthToken.calledWith({'interactive': true}));
// Request another token.
promptForConsent.reset();
@@ -69,33 +72,33 @@ test('consent is requested only on first invocation', function() {
return identity.getToken();
}).then(function(/** string */ token) {
- ok(!promptForConsent.called);
- ok(getAuthToken.calledOnce);
- ok(getAuthToken.calledWith({'interactive': true}));
- equal(token, 'token');
+ assert.ok(!promptForConsent.called);
+ assert.ok(getAuthToken.calledOnce);
+ assert.ok(getAuthToken.calledWith({'interactive': true}));
+ assert.equal(token, 'token');
});
});
-test('cancellations are reported correctly', function() {
+QUnit.test('cancellations are reported correctly', function(assert) {
consentDialog.grantConsent = false;
chromeMocks.runtime.lastError.message = 'The user did not approve access.';
return identity.getToken().then(
function(/** string */ token) {
- ok(false, 'expected getToken() to fail');
+ assert.ok(false, 'expected getToken() to fail');
}).catch(function(/** remoting.Error */ error) {
- equal(error.getTag(), remoting.Error.Tag.CANCELLED);
+ assert.equal(error.getTag(), remoting.Error.Tag.CANCELLED);
});
});
-test('other errors are reported correctly', function() {
+QUnit.test('other errors are reported correctly', function(assert) {
consentDialog.grantConsent = false;
chromeMocks.runtime.lastError.message = '<some other error message>';
return identity.getToken().then(
function(/** string */ token) {
- ok(false, 'expected getToken() to fail');
+ assert.ok(false, 'expected getToken() to fail');
}).catch(function(/** remoting.Error */ error) {
- equal(error.getTag(), remoting.Error.Tag.NOT_AUTHENTICATED);
+ assert.equal(error.getTag(), remoting.Error.Tag.NOT_AUTHENTICATED);
});
});
« no previous file with comments | « remoting/webapp/crd/js/host_table_entry_unittest.js ('k') | remoting/webapp/crd/js/l10n_unittest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698