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

Side by Side Diff: remoting/webapp/crd/js/host_list_api_impl_unittest.js

Issue 1111603002: Added ability to register new hosts using GCD. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@host-list-delete
Patch Set: Created 5 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * Unit tests for host_controller.js. 7 * Unit tests for host_controller.js.
8 */ 8 */
9 9
10 (function() { 10 (function() {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 58 }
59 59
60 QUnit.test('register with auth code', function(assert) { 60 QUnit.test('register with auth code', function(assert) {
61 var impl = new remoting.HostListApiImpl(); 61 var impl = new remoting.HostListApiImpl();
62 queueRegistryResponse(assert, true); 62 queueRegistryResponse(assert, true);
63 return impl.register( 63 return impl.register(
64 FAKE_HOST_ID, 64 FAKE_HOST_ID,
65 FAKE_HOST_NAME, 65 FAKE_HOST_NAME,
66 FAKE_PUBLIC_KEY, 66 FAKE_PUBLIC_KEY,
67 FAKE_HOST_CLIENT_ID 67 FAKE_HOST_CLIENT_ID
68 ). then(function(authCode) { 68 ). then(function(regResult) {
69 assert.equal(authCode, FAKE_AUTH_CODE); 69 assert.equal(regResult.authCode, FAKE_AUTH_CODE);
70 assert.equal(regResult.email, '');
70 }); 71 });
71 }); 72 });
72 73
73 QUnit.test('register without auth code', function(assert) { 74 QUnit.test('register without auth code', function(assert) {
74 var impl = new remoting.HostListApiImpl(); 75 var impl = new remoting.HostListApiImpl();
75 queueRegistryResponse(assert, false); 76 queueRegistryResponse(assert, false);
76 return impl.register( 77 return impl.register(
77 FAKE_HOST_ID, 78 FAKE_HOST_ID,
78 FAKE_HOST_NAME, 79 FAKE_HOST_NAME,
79 FAKE_PUBLIC_KEY, 80 FAKE_PUBLIC_KEY,
80 FAKE_HOST_CLIENT_ID 81 FAKE_HOST_CLIENT_ID
81 ). then(function(authCode) { 82 ). then(function(regResult) {
82 assert.equal(authCode, ''); 83 assert.equal(regResult.authCode, '');
84 assert.equal(regResult.email, '');
83 }); 85 });
84 }); 86 });
85 87
86 QUnit.test('register failure', function(assert) { 88 QUnit.test('register failure', function(assert) {
87 var impl = new remoting.HostListApiImpl(); 89 var impl = new remoting.HostListApiImpl();
88 remoting.MockXhr.setEmptyResponseFor( 90 remoting.MockXhr.setEmptyResponseFor(
89 'POST', 'DIRECTORY_API_BASE_URL/@me/hosts', 500); 91 'POST', 'DIRECTORY_API_BASE_URL/@me/hosts', 500);
90 return impl.register( 92 return impl.register(
91 FAKE_HOST_ID, 93 FAKE_HOST_ID,
92 FAKE_HOST_NAME, 94 FAKE_HOST_NAME,
93 FAKE_PUBLIC_KEY, 95 FAKE_PUBLIC_KEY,
94 FAKE_HOST_CLIENT_ID 96 FAKE_HOST_CLIENT_ID
95 ).then(function(authCode) { 97 ).then(function(authCode) {
96 throw 'test failed'; 98 throw 'test failed';
97 }, function(/** remoting.Error */ e) { 99 }, function(/** remoting.Error */ e) {
98 assert.equal(e.getTag(), remoting.Error.Tag.REGISTRATION_FAILED); 100 assert.equal(e.getTag(), remoting.Error.Tag.REGISTRATION_FAILED);
99 }); 101 });
100 }); 102 });
101 103
102 })(); 104 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698