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

Side by Side Diff: remoting/webapp/unittests/base_unittest.js

Issue 1002553002: Refactor sinon helper to make it easier to use. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
OLDNEW
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 module('base'); 9 module('base');
10 10
11 test('mix(dest, src) should copy properties from |src| to |dest|', 11 test('mix(dest, src) should copy properties from |src| to |dest|',
12 function() { 12 function() {
13 var src = { a: 'a', b: 'b'}; 13 var src = { a: 'a', b: 'b'};
14 var dest = { c: 'c'}; 14 var dest = { c: 'c'};
15 15
16 base.mix(dest, src); 16 base.mix(dest, src);
17 deepEqual(dest, {a: 'a', b: 'b', c: 'c'}); 17 deepEqual(dest, {a: 'a', b: 'b', c: 'c'});
18 }); 18 });
19 19
20 test('mix(dest, src) should assert if properties are overwritten', 20 test('mix(dest, src) should assert if properties are overwritten',
21 function() { 21 function() {
22 var src = { a: 'a', b: 'b'}; 22 var src = { a: 'a', b: 'b'};
23 var dest = { a: 'a'}; 23 var dest = { a: 'a'};
24 24
25 sinon.$setupStub(base.debug, 'assert'); 25 sinon.stub(base.debug, 'assert');
26 26
27 try { 27 try {
28 base.mix(dest, src); 28 base.mix(dest, src);
29 } catch (e) { 29 } catch (e) {
30 } finally { 30 } finally {
31 sinon.assert.called(base.debug.assert); 31 sinon.assert.called(base.debug.assert);
32 base.debug.assert.$testStub.restore(); 32 $testStub(base.debug.assert).restore();
33 } 33 }
34 }); 34 });
35 35
36 test('values(obj) should return an array containing the values of |obj|', 36 test('values(obj) should return an array containing the values of |obj|',
37 function() { 37 function() {
38 var output = base.values({ a: 'a', b: 'b'}); 38 var output = base.values({ a: 'a', b: 'b'});
39 39
40 notEqual(output.indexOf('a'), -1, '"a" should be in the output'); 40 notEqual(output.indexOf('a'), -1, '"a" should be in the output');
41 notEqual(output.indexOf('b'), -1, '"b" should be in the output'); 41 notEqual(output.indexOf('b'), -1, '"b" should be in the output');
42 }); 42 });
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 }); 237 });
238 238
239 test('raiseEvent() should not invoke listeners of a different event', 239 test('raiseEvent() should not invoke listeners of a different event',
240 function() { 240 function() {
241 source.raiseEvent('bar'); 241 source.raiseEvent('bar');
242 sinon.assert.notCalled(listener); 242 sinon.assert.notCalled(listener);
243 }); 243 });
244 244
245 test('raiseEvent() should assert when undeclared events are raised', 245 test('raiseEvent() should assert when undeclared events are raised',
246 function() { 246 function() {
247 sinon.$setupStub(base.debug, 'assert'); 247 sinon.stub(base.debug, 'assert');
248 try { 248 try {
249 source.raiseEvent('undefined'); 249 source.raiseEvent('undefined');
250 } catch (e) { 250 } catch (e) {
251 } finally { 251 } finally {
252 sinon.assert.called(base.debug.assert); 252 sinon.assert.called(base.debug.assert);
253 base.debug.assert.$testStub.restore(); 253 $testStub(base.debug.assert).restore();
254 } 254 }
255 }); 255 });
256 256
257 test( 257 test(
258 'removeEventListener() should not invoke the listener in subsequent ' + 258 'removeEventListener() should not invoke the listener in subsequent ' +
259 'calls to |raiseEvent|', 259 'calls to |raiseEvent|',
260 function() { 260 function() {
261 source.raiseEvent('foo'); 261 source.raiseEvent('foo');
262 sinon.assert.calledOnce(listener); 262 sinon.assert.calledOnce(listener);
263 263
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 /* Ѓ */ 0xD0, 0x83, 318 /* Ѓ */ 0xD0, 0x83,
319 /* ф */ 0xD1, 0x84]).buffer), 319 /* ф */ 0xD1, 0x84]).buffer),
320 "挂Ѓф"); 320 "挂Ѓф");
321 321
322 // Unicode surrogate pair for U+1F603. 322 // Unicode surrogate pair for U+1F603.
323 QUnit.equal(base.decodeUtf8(new Uint8Array([0xF0, 0x9F, 0x98, 0x83]).buffer), 323 QUnit.equal(base.decodeUtf8(new Uint8Array([0xF0, 0x9F, 0x98, 0x83]).buffer),
324 "😃"); 324 "😃");
325 }); 325 });
326 326
327 })(); 327 })();
OLDNEW
« no previous file with comments | « remoting/webapp/unittests/apps_v2_migration_unittest.js ('k') | remoting/webapp/unittests/host_table_entry_unittest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698