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

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

Issue 959963002: [Chromoting] Enable jscompile for webapp unittests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename sinon.$testStub -> sinon.TestStub 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 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 /**
6 * @fileoverview
7 * TODO(garykac): Create interface for SignalStrategy.
8 * @suppress {checkTypes|checkVars|reportUnknownTypes|visibility}
9 */
10
5 (function() { 11 (function() {
6 12
7 'use strict'; 13 'use strict';
8 14
15 /** @type {(sinon.Spy|function(remoting.SignalStrategy.State))} */
9 var onStateChange = null; 16 var onStateChange = null;
17
18 /** @type {(sinon.Spy|function(Element):void)} */
10 var onIncomingStanzaCallback = null; 19 var onIncomingStanzaCallback = null;
20
21 /** @type {remoting.DnsBlackholeChecker} */
11 var checker = null; 22 var checker = null;
23
24 /** @type {remoting.MockSignalStrategy} */
12 var signalStrategy = null; 25 var signalStrategy = null;
13 var fakeXhrs; 26 var fakeXhrs;
14 27
15 module('dns_blackhole_checker', { 28 module('dns_blackhole_checker', {
16 setup: function() { 29 setup: function() {
17 fakeXhrs = []; 30 fakeXhrs = [];
18 sinon.useFakeXMLHttpRequest().onCreate = function(xhr) { 31 sinon.useFakeXMLHttpRequest().onCreate = function(xhr) {
19 fakeXhrs.push(xhr); 32 fakeXhrs.push(xhr);
20 }; 33 };
21 34
22
23 onStateChange = sinon.spy(); 35 onStateChange = sinon.spy();
24 onIncomingStanzaCallback = sinon.spy(); 36 onIncomingStanzaCallback = sinon.spy();
25 signalStrategy = new remoting.MockSignalStrategy(); 37 signalStrategy = new remoting.MockSignalStrategy();
26 checker = new remoting.DnsBlackholeChecker(signalStrategy); 38 checker = new remoting.DnsBlackholeChecker(signalStrategy);
27 39
28 checker.setStateChangedCallback(onStateChange); 40 checker.setStateChangedCallback(onStateChange);
29 checker.setIncomingStanzaCallback(onIncomingStanzaCallback); 41 checker.setIncomingStanzaCallback(onIncomingStanzaCallback);
30 42
31 sinon.assert.notCalled(onStateChange); 43 sinon.assert.notCalled(onStateChange);
32 sinon.assert.notCalled(signalStrategy.connect); 44 sinon.assert.notCalled(signalStrategy.connect);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 // Verify that DnsBlackholeChecker goes to FAILED state after it gets the 161 // Verify that DnsBlackholeChecker goes to FAILED state after it gets the
150 // blocked HTTP response. 162 // blocked HTTP response.
151 fakeXhrs[0].respond(400); 163 fakeXhrs[0].respond(400);
152 sinon.assert.calledWith(onStateChange, 164 sinon.assert.calledWith(onStateChange,
153 remoting.SignalStrategy.State.FAILED); 165 remoting.SignalStrategy.State.FAILED);
154 equal(checker.getError(), remoting.Error.NOT_AUTHORIZED); 166 equal(checker.getError(), remoting.Error.NOT_AUTHORIZED);
155 } 167 }
156 ); 168 );
157 169
158 })(); 170 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698