| OLD | NEW |
| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 }); | 59 }); |
| 60 } | 60 } |
| 61 | 61 |
| 62 QUnit.test('register', function(assert) { | 62 QUnit.test('register', function(assert) { |
| 63 var impl = new remoting.LegacyHostListApi(); | 63 var impl = new remoting.LegacyHostListApi(); |
| 64 queueRegistryResponse(assert); | 64 queueRegistryResponse(assert); |
| 65 return impl.register( | 65 return impl.register( |
| 66 FAKE_HOST_NAME, | 66 FAKE_HOST_NAME, |
| 67 FAKE_PUBLIC_KEY, | 67 FAKE_PUBLIC_KEY, |
| 68 FAKE_HOST_CLIENT_ID | 68 FAKE_HOST_CLIENT_ID |
| 69 ). then(function(regResult) { | 69 ).then(function(regResult) { |
| 70 assert.equal(regResult.authCode, FAKE_AUTH_CODE); | 70 assert.equal(regResult.authCode, FAKE_AUTH_CODE); |
| 71 assert.equal(regResult.email, ''); | 71 assert.equal(regResult.email, ''); |
| 72 }); | 72 }); |
| 73 }); | 73 }); |
| 74 | 74 |
| 75 QUnit.test('register failure', function(assert) { | 75 QUnit.test('register failure', function(assert) { |
| 76 var impl = new remoting.LegacyHostListApi(); | 76 var impl = new remoting.LegacyHostListApi(); |
| 77 remoting.MockXhr.setEmptyResponseFor( | 77 remoting.MockXhr.setEmptyResponseFor( |
| 78 'POST', 'DIRECTORY_API_BASE_URL/@me/hosts', 500); | 78 'POST', 'DIRECTORY_API_BASE_URL/@me/hosts', 500); |
| 79 return impl.register( | 79 return impl.register( |
| 80 FAKE_HOST_NAME, | 80 FAKE_HOST_NAME, |
| 81 FAKE_PUBLIC_KEY, | 81 FAKE_PUBLIC_KEY, |
| 82 FAKE_HOST_CLIENT_ID | 82 FAKE_HOST_CLIENT_ID |
| 83 ).then(function(authCode) { | 83 ).then(function(authCode) { |
| 84 throw 'test failed'; | 84 throw 'test failed'; |
| 85 }, function(/** remoting.Error */ e) { | 85 }, function(/** remoting.Error */ e) { |
| 86 assert.equal(e.getTag(), remoting.Error.Tag.REGISTRATION_FAILED); | 86 assert.equal(e.getTag(), remoting.Error.Tag.REGISTRATION_FAILED); |
| 87 }); | 87 }); |
| 88 }); | 88 }); |
| 89 | 89 |
| 90 })(); | 90 })(); |
| OLD | NEW |