| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 | 6 |
| 7 'use strict'; | 7 'use strict'; |
| 8 | 8 |
| 9 QUnit.module('base'); | 9 var getRandomValuesStub = null; |
| 10 |
| 11 QUnit.module('base', { |
| 12 afterEach: function() { |
| 13 if (getRandomValuesStub) { |
| 14 getRandomValuesStub.restore(); |
| 15 getRandomValuesStub = null; |
| 16 } |
| 17 } |
| 18 }); |
| 10 | 19 |
| 11 QUnit.test('mix(dest, src) should copy properties from |src| to |dest|', | 20 QUnit.test('mix(dest, src) should copy properties from |src| to |dest|', |
| 12 function(assert) { | 21 function(assert) { |
| 13 var src = { a: 'a', b: 'b'}; | 22 var src = { a: 'a', b: 'b'}; |
| 14 var dest = { c: 'c'}; | 23 var dest = { c: 'c'}; |
| 15 | 24 |
| 16 base.mix(dest, src); | 25 base.mix(dest, src); |
| 17 assert.deepEqual(dest, {a: 'a', b: 'b', c: 'c'}); | 26 assert.deepEqual(dest, {a: 'a', b: 'b', c: 'c'}); |
| 18 }); | 27 }); |
| 19 | 28 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 assert.ok(false); | 202 assert.ok(false); |
| 194 }).then(function() { | 203 }).then(function() { |
| 195 return base.Promise.negate(Promise.resolve()); | 204 return base.Promise.negate(Promise.resolve()); |
| 196 }).then(function() { | 205 }).then(function() { |
| 197 assert.ok(false); | 206 assert.ok(false); |
| 198 }).catch(function() { | 207 }).catch(function() { |
| 199 assert.ok(true); | 208 assert.ok(true); |
| 200 }); | 209 }); |
| 201 }); | 210 }); |
| 202 | 211 |
| 212 QUnit.test('generateUuid generates a UUID', function(assert) { |
| 213 getRandomValuesStub = sinon.stub( |
| 214 window.crypto, 'getRandomValues', function(/** Uint16Array*/ out) { |
| 215 for (var i = 0; i < out.length; i++) { |
| 216 out[i] = i; |
| 217 } |
| 218 }); |
| 219 assert.equal(base.generateUuid(), '00000001-0002-0003-0004-000500060007'); |
| 220 }); |
| 221 |
| 203 QUnit.module('base.Deferred'); | 222 QUnit.module('base.Deferred'); |
| 204 | 223 |
| 205 QUnit.test('resolve() should fulfill the underlying promise.', function(assert){ | 224 QUnit.test('resolve() should fulfill the underlying promise.', function(assert){ |
| 206 /** @returns {Promise} */ | 225 /** @returns {Promise} */ |
| 207 function async() { | 226 function async() { |
| 208 var deferred = new base.Deferred(); | 227 var deferred = new base.Deferred(); |
| 209 deferred.resolve('bar'); | 228 deferred.resolve('bar'); |
| 210 return deferred.promise(); | 229 return deferred.promise(); |
| 211 } | 230 } |
| 212 | 231 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 /* Ѓ */ 0xD0, 0x83, | 378 /* Ѓ */ 0xD0, 0x83, |
| 360 /* ф */ 0xD1, 0x84]).buffer), | 379 /* ф */ 0xD1, 0x84]).buffer), |
| 361 "挂Ѓф"); | 380 "挂Ѓф"); |
| 362 | 381 |
| 363 // Unicode surrogate pair for U+1F603. | 382 // Unicode surrogate pair for U+1F603. |
| 364 assert.equal(base.decodeUtf8(new Uint8Array([0xF0, 0x9F, 0x98, 0x83]).buffer), | 383 assert.equal(base.decodeUtf8(new Uint8Array([0xF0, 0x9F, 0x98, 0x83]).buffer), |
| 365 "😃"); | 384 "😃"); |
| 366 }); | 385 }); |
| 367 | 386 |
| 368 })(); | 387 })(); |
| OLD | NEW |