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

Side by Side Diff: remoting/webapp/crd/js/error_unittest.js

Issue 1017613002: Migrate Remoting Webapp Unittests to use QUnit 2.0 syntax. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Migrate to assert 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 QUnit.module('error', { 9 QUnit.module('error');
10 setup: function() { 10
11 }, 11 QUnit.test('error constructor 1', function(assert) {
12 teardown: function() { 12 var error = new remoting.Error(remoting.Error.Tag.HOST_OVERLOAD);
13 } 13 assert.equal(error.getTag(), remoting.Error.Tag.HOST_OVERLOAD);
14 assert.equal(error.toString(), remoting.Error.Tag.HOST_OVERLOAD);
14 }); 15 });
15 16
16 QUnit.test('error constructor 1', function() { 17 QUnit.test('error constructor 2', function(assert) {
17 var error = new remoting.Error(remoting.Error.Tag.HOST_OVERLOAD);
18 QUnit.equal(error.getTag(), remoting.Error.Tag.HOST_OVERLOAD);
19 QUnit.equal(error.toString(), remoting.Error.Tag.HOST_OVERLOAD);
20 });
21
22 QUnit.test('error constructor 2', function() {
23 var error = new remoting.Error( 18 var error = new remoting.Error(
24 remoting.Error.Tag.HOST_IS_OFFLINE, 19 remoting.Error.Tag.HOST_IS_OFFLINE,
25 'detail'); 20 'detail');
26 QUnit.equal(error.getTag(), remoting.Error.Tag.HOST_IS_OFFLINE); 21 assert.equal(error.getTag(), remoting.Error.Tag.HOST_IS_OFFLINE);
27 QUnit.ok(error.toString().indexOf(remoting.Error.Tag.HOST_IS_OFFLINE) != -1); 22 assert.ok(error.toString().indexOf(remoting.Error.Tag.HOST_IS_OFFLINE) != -1);
28 QUnit.ok(error.toString().indexOf('detail') != -1); 23 assert.ok(error.toString().indexOf('detail') != -1);
29 }); 24 });
30 25
31 QUnit.test('hasTag', function() { 26 QUnit.test('hasTag', function(assert) {
32 var error = new remoting.Error(remoting.Error.Tag.HOST_OVERLOAD); 27 var error = new remoting.Error(remoting.Error.Tag.HOST_OVERLOAD);
33 QUnit.ok(error.hasTag(remoting.Error.Tag.HOST_OVERLOAD)); 28 assert.ok(error.hasTag(remoting.Error.Tag.HOST_OVERLOAD));
34 QUnit.ok(error.hasTag( 29 assert.ok(error.hasTag(
35 remoting.Error.Tag.HOST_OVERLOAD, 30 remoting.Error.Tag.HOST_OVERLOAD,
36 remoting.Error.Tag.HOST_IS_OFFLINE)); 31 remoting.Error.Tag.HOST_IS_OFFLINE));
37 QUnit.ok(!error.hasTag(remoting.Error.Tag.HOST_IS_OFFLINE)); 32 assert.ok(!error.hasTag(remoting.Error.Tag.HOST_IS_OFFLINE));
38 }); 33 });
39 34
40 QUnit.test('constructor methods', function() { 35 QUnit.test('constructor methods', function(assert) {
41 QUnit.ok(remoting.Error.none().hasTag(remoting.Error.Tag.NONE)); 36 assert.ok(remoting.Error.none().hasTag(remoting.Error.Tag.NONE));
42 QUnit.ok(remoting.Error.unexpected().hasTag(remoting.Error.Tag.UNEXPECTED)); 37 assert.ok(remoting.Error.unexpected().hasTag(remoting.Error.Tag.UNEXPECTED));
43 }); 38 });
44 39
45 QUnit.test('isNone', function() { 40 QUnit.test('isNone', function(assert) {
46 QUnit.ok(remoting.Error.none().isNone()); 41 assert.ok(remoting.Error.none().isNone());
47 QUnit.ok(!remoting.Error.unexpected().isNone()); 42 assert.ok(!remoting.Error.unexpected().isNone());
48 QUnit.ok(!new remoting.Error(remoting.Error.Tag.CANCELLED).isNone()); 43 assert.ok(!new remoting.Error(remoting.Error.Tag.CANCELLED).isNone());
49 }); 44 });
50 45
51 46
52 QUnit.test('fromHttpStatus', function() { 47 QUnit.test('fromHttpStatus', function(assert) {
53 QUnit.ok(remoting.Error.fromHttpStatus(200).isNone()); 48 assert.ok(remoting.Error.fromHttpStatus(200).isNone());
54 QUnit.ok(remoting.Error.fromHttpStatus(201).isNone()); 49 assert.ok(remoting.Error.fromHttpStatus(201).isNone());
55 QUnit.ok(!remoting.Error.fromHttpStatus(500).isNone()); 50 assert.ok(!remoting.Error.fromHttpStatus(500).isNone());
56 QUnit.equal( 51 assert.equal(
57 remoting.Error.fromHttpStatus(0).getTag(), 52 remoting.Error.fromHttpStatus(0).getTag(),
58 remoting.Error.Tag.NETWORK_FAILURE); 53 remoting.Error.Tag.NETWORK_FAILURE);
59 QUnit.equal( 54 assert.equal(
60 remoting.Error.fromHttpStatus(100).getTag(), 55 remoting.Error.fromHttpStatus(100).getTag(),
61 remoting.Error.Tag.UNEXPECTED); 56 remoting.Error.Tag.UNEXPECTED);
62 QUnit.equal( 57 assert.equal(
63 remoting.Error.fromHttpStatus(200).getTag(), 58 remoting.Error.fromHttpStatus(200).getTag(),
64 remoting.Error.Tag.NONE); 59 remoting.Error.Tag.NONE);
65 QUnit.equal( 60 assert.equal(
66 remoting.Error.fromHttpStatus(201).getTag(), 61 remoting.Error.fromHttpStatus(201).getTag(),
67 remoting.Error.Tag.NONE); 62 remoting.Error.Tag.NONE);
68 QUnit.equal( 63 assert.equal(
69 remoting.Error.fromHttpStatus(400).getTag(), 64 remoting.Error.fromHttpStatus(400).getTag(),
70 remoting.Error.Tag.AUTHENTICATION_FAILED); 65 remoting.Error.Tag.AUTHENTICATION_FAILED);
71 QUnit.equal( 66 assert.equal(
72 remoting.Error.fromHttpStatus(401).getTag(), 67 remoting.Error.fromHttpStatus(401).getTag(),
73 remoting.Error.Tag.AUTHENTICATION_FAILED); 68 remoting.Error.Tag.AUTHENTICATION_FAILED);
74 QUnit.equal( 69 assert.equal(
75 remoting.Error.fromHttpStatus(402).getTag(), 70 remoting.Error.fromHttpStatus(402).getTag(),
76 remoting.Error.Tag.UNEXPECTED); 71 remoting.Error.Tag.UNEXPECTED);
77 QUnit.equal( 72 assert.equal(
78 remoting.Error.fromHttpStatus(403).getTag(), 73 remoting.Error.fromHttpStatus(403).getTag(),
79 remoting.Error.Tag.NOT_AUTHORIZED); 74 remoting.Error.Tag.NOT_AUTHORIZED);
80 QUnit.equal( 75 assert.equal(
81 remoting.Error.fromHttpStatus(404).getTag(), 76 remoting.Error.fromHttpStatus(404).getTag(),
82 remoting.Error.Tag.NOT_FOUND); 77 remoting.Error.Tag.NOT_FOUND);
83 QUnit.equal( 78 assert.equal(
84 remoting.Error.fromHttpStatus(500).getTag(), 79 remoting.Error.fromHttpStatus(500).getTag(),
85 remoting.Error.Tag.SERVICE_UNAVAILABLE); 80 remoting.Error.Tag.SERVICE_UNAVAILABLE);
86 QUnit.equal( 81 assert.equal(
87 remoting.Error.fromHttpStatus(501).getTag(), 82 remoting.Error.fromHttpStatus(501).getTag(),
88 remoting.Error.Tag.SERVICE_UNAVAILABLE); 83 remoting.Error.Tag.SERVICE_UNAVAILABLE);
89 QUnit.equal( 84 assert.equal(
90 remoting.Error.fromHttpStatus(600).getTag(), 85 remoting.Error.fromHttpStatus(600).getTag(),
91 remoting.Error.Tag.UNEXPECTED); 86 remoting.Error.Tag.UNEXPECTED);
92 }); 87 });
93 88
94 QUnit.test('handler 1', function() { 89 QUnit.test('handler 1', function(assert) {
95 /** @type {!remoting.Error} */ 90 /** @type {!remoting.Error} */
96 var reportedError; 91 var reportedError;
97 var onError = function(/** !remoting.Error */ arg) { 92 var onError = function(/** !remoting.Error */ arg) {
98 reportedError = arg; 93 reportedError = arg;
99 }; 94 };
100 remoting.Error.handler(onError)('not a real tag'); 95 remoting.Error.handler(onError)('not a real tag');
101 QUnit.ok(reportedError instanceof remoting.Error); 96 assert.ok(reportedError instanceof remoting.Error);
102 QUnit.equal(reportedError.getTag(), remoting.Error.Tag.UNEXPECTED); 97 assert.equal(reportedError.getTag(), remoting.Error.Tag.UNEXPECTED);
103 }); 98 });
104 99
105 100
106 QUnit.test('handler 2', function() { 101 QUnit.test('handler 2', function(assert) {
107 /** @type {!remoting.Error} */ 102 /** @type {!remoting.Error} */
108 var reportedError; 103 var reportedError;
109 var onError = function(/** !remoting.Error */ arg) { 104 var onError = function(/** !remoting.Error */ arg) {
110 reportedError = arg; 105 reportedError = arg;
111 }; 106 };
112 var origError = new remoting.Error(remoting.Error.Tag.HOST_IS_OFFLINE); 107 var origError = new remoting.Error(remoting.Error.Tag.HOST_IS_OFFLINE);
113 remoting.Error.handler(onError)(origError); 108 remoting.Error.handler(onError)(origError);
114 QUnit.equal(reportedError, origError); 109 assert.equal(reportedError, origError);
115 }); 110 });
116 111
117 })(); 112 })();
OLDNEW
« no previous file with comments | « remoting/webapp/crd/js/dns_blackhole_checker_unittest.js ('k') | remoting/webapp/crd/js/fallback_signal_strategy_unittest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698