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

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

Issue 376803005: JavaScript unit test framework for Chrome remote desktop - Part II (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « remoting/webapp/html/template_unittest.html ('k') | third_party/qunit/README.chromium » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 var source = null; 9 var source = null;
10 var listener = null; 10 var listener = null;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 source.defineEvents(['foo', 'bar']); 69 source.defineEvents(['foo', 'bar']);
70 }, 70 },
71 teardown: function() { 71 teardown: function() {
72 source = null; 72 source = null;
73 listener = null; 73 listener = null;
74 } 74 }
75 }); 75 });
76 76
77 test('should not invoke the listener in subsequent calls to |raiseEvent|', 77 test('should not invoke the listener in subsequent calls to |raiseEvent|',
78 function() { 78 function() {
79 var numCalled = 0;
80 listener = sinon.spy(); 79 listener = sinon.spy();
81 source.addEventListener('foo', listener); 80 source.addEventListener('foo', listener);
82 81
83 source.raiseEvent('foo'); 82 source.raiseEvent('foo');
84 sinon.assert.calledOnce(listener); 83 sinon.assert.calledOnce(listener);
85 84
86 source.removeEventListener('foo', listener); 85 source.removeEventListener('foo', listener);
87 source.raiseEvent('foo'); 86 source.raiseEvent('foo');
88 sinon.assert.calledOnce(listener); 87 sinon.assert.calledOnce(listener);
89 }); 88 });
90 89
91 test('should work even if the listener is removed during |raiseEvent|', 90 test('should work even if the listener is removed during |raiseEvent|',
92 function() { 91 function() {
93 var numCalled = 0;
94 var sink = {}; 92 var sink = {};
95 sink.listener = sinon.spy(function() { 93 sink.listener = sinon.spy(function() {
96 source.removeEventListener('foo', sink.listener); 94 source.removeEventListener('foo', sink.listener);
97 }); 95 });
98 96
99 source.addEventListener('foo', sink.listener); 97 source.addEventListener('foo', sink.listener);
100 source.raiseEvent('foo'); 98 source.raiseEvent('foo');
101 sinon.assert.calledOnce(sink.listener); 99 sinon.assert.calledOnce(sink.listener);
102 100
103 source.raiseEvent('foo'); 101 source.raiseEvent('foo');
104 sinon.assert.calledOnce(sink.listener); 102 sinon.assert.calledOnce(sink.listener);
105 }); 103 });
106 104
107 })(); 105 })();
OLDNEW
« no previous file with comments | « remoting/webapp/html/template_unittest.html ('k') | third_party/qunit/README.chromium » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698