| 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 (function() { | 5 (function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** @type {boolean} */ | 8 /** @type {boolean} */ |
| 9 var oldThrowOnAssert; | 9 var oldThrowOnAssert; |
| 10 | 10 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 var promise = sendRequest(); | 65 var promise = sendRequest(); |
| 66 assert.throws(sendRequest); | 66 assert.throws(sendRequest); |
| 67 return promise.then(function(/** remoting.Xhr.Response */ result) { | 67 return promise.then(function(/** remoting.Xhr.Response */ result) { |
| 68 assert.equal(result.status, 204); | 68 assert.equal(result.status, 204); |
| 69 assert.equal(result.getText(), ''); | 69 assert.equal(result.getText(), ''); |
| 70 assert.throws(result.getJson.bind(result)); | 70 assert.throws(result.getJson.bind(result)); |
| 71 }); | 71 }); |
| 72 }); | 72 }); |
| 73 | 73 |
| 74 QUnit.test('setEmptyResponseFor with repeat', function(assert) { | 74 QUnit.test('setEmptyResponseFor with repeat', function(assert) { |
| 75 remoting.MockXhr.setEmptyResponseFor('GET', 'http://foo.com', true); | 75 remoting.MockXhr.setEmptyResponseFor('GET', 'http://foo.com', 404, true); |
| 76 var promise1 = sendRequest(); | 76 var promise1 = sendRequest(); |
| 77 var promise2 = sendRequest(); | 77 var promise2 = sendRequest(); |
| 78 return promise1.then(function(/** remoting.Xhr.Response */ result) { | 78 return promise1.then(function(/** remoting.Xhr.Response */ result) { |
| 79 assert.equal(result.status, 204); | 79 assert.equal(result.status, 404); |
| 80 assert.equal(result.getText(), ''); | 80 assert.equal(result.getText(), ''); |
| 81 assert.throws(result.getJson.bind(result)); | 81 assert.throws(result.getJson.bind(result)); |
| 82 return promise2; | 82 return promise2; |
| 83 }).then(function(/** remoting.Xhr.Response */ result) { | 83 }).then(function(/** remoting.Xhr.Response */ result) { |
| 84 assert.equal(result.status, 204); | 84 assert.equal(result.status, 404); |
| 85 assert.equal(result.getText(), ''); | 85 assert.equal(result.getText(), ''); |
| 86 assert.throws(result.getJson.bind(result)); | 86 assert.throws(result.getJson.bind(result)); |
| 87 }); | 87 }); |
| 88 }); | 88 }); |
| 89 | 89 |
| 90 QUnit.test('setEmptyResponseFor with RegExp', function(assert) { | 90 QUnit.test('setEmptyResponseFor with RegExp', function(assert) { |
| 91 remoting.MockXhr.setEmptyResponseFor('GET', /foo/); | 91 remoting.MockXhr.setEmptyResponseFor('GET', /foo/); |
| 92 var promise = sendRequest(); | 92 var promise = sendRequest(); |
| 93 assert.throws(sendRequest); | 93 assert.throws(sendRequest); |
| 94 return promise.then(function(/** remoting.Xhr.Response */ result) { | 94 return promise.then(function(/** remoting.Xhr.Response */ result) { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 var promise = sendRequestForJson(); | 162 var promise = sendRequestForJson(); |
| 163 assert.throws(sendRequestForJson); | 163 assert.throws(sendRequestForJson); |
| 164 return promise.then(function(/** remoting.Xhr.Response */ result) { | 164 return promise.then(function(/** remoting.Xhr.Response */ result) { |
| 165 assert.equal(result.status, 200); | 165 assert.equal(result.status, 200); |
| 166 assert.equal(JSON.parse(result.getText()), 'foo'); | 166 assert.equal(JSON.parse(result.getText()), 'foo'); |
| 167 assert.equal(result.getJson(), 'foo'); | 167 assert.equal(result.getJson(), 'foo'); |
| 168 }); | 168 }); |
| 169 }); | 169 }); |
| 170 | 170 |
| 171 })(); | 171 })(); |
| OLD | NEW |