Skip to content

Commit db281c1

Browse files
m-amrpetebacondarwin
authored andcommitted
refactor(*): use toBeUndefined consistently
Closes angular#14185 Fixes angular#14184
1 parent 6a336ba commit db281c1

18 files changed

+59
-59
lines changed

docs/content/guide/unit-testing.ngdoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ describe("Deep Thought", function() {
454454
beforeAll(module("UltimateQuestion"));
455455

456456
beforeAll(inject(function(DeepThought) {
457-
expect(DeepThought.answer).toBe(undefined);
457+
expect(DeepThought.answer).toBeUndefined();
458458
DeepThought.generateAnswer();
459459
}));
460460

i18n/spec/closureI18nExtractorSpec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ describe("serializeContent", function() {
272272
it("should not transform arrays into objects", function() {
273273
var serializedContent = closureI18nExtractor.serializeContent(newTestLocaleInfo().fr_CA);
274274
var deserializedLocale = eval("(" + serializedContent + ")");
275-
expect(deserializedLocale.DATETIME_FORMATS.MONTH.length).not.toBe(undefined);
275+
expect(deserializedLocale.DATETIME_FORMATS.MONTH.length).not.toBeUndefined();
276276
});
277277
});
278278

src/ngMock/angular-mocks.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2670,7 +2670,7 @@ angular.mock.$RootScopeDecorator = ['$delegate', function($delegate) {
26702670
* beforeAll(module("UltimateQuestion"));
26712671
*
26722672
* beforeAll(inject(function(DeepThought) {
2673-
* expect(DeepThought.answer).toBe(undefined);
2673+
* expect(DeepThought.answer).toBeUndefined();
26742674
* DeepThought.generateAnswer();
26752675
* }));
26762676
*

test/AngularSpec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ describe('angular', function() {
10681068
});
10691069

10701070
it('should return undefined when jq is not set, no jQuery found (the default)', function() {
1071-
expect(jq()).toBe(undefined);
1071+
expect(jq()).toBeUndefined();
10721072
});
10731073

10741074
it('should return empty string when jq is enabled manually via [ng-jq] with empty string', function() {

test/ApiSpecs.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ describe('api', function() {
1111
map.put(key, value1);
1212
map.put(key, value2);
1313
expect(map.get(key)).toBe(value2);
14-
expect(map.get({})).toBe(undefined);
14+
expect(map.get({})).toBeUndefined();
1515
expect(map.remove(key)).toBe(value2);
16-
expect(map.get(key)).toBe(undefined);
16+
expect(map.get(key)).toBeUndefined();
1717
});
1818

1919
it('should init from an array', function() {
2020
var map = new HashMap(['a','b']);
2121
expect(map.get('a')).toBe(0);
2222
expect(map.get('b')).toBe(1);
23-
expect(map.get('c')).toBe(undefined);
23+
expect(map.get('c')).toBeUndefined();
2424
});
2525

2626
it('should maintain hashKey for object keys', function() {

test/jqLiteSpec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ describe('jqLite', function() {
356356

357357
expect(div.controller()).toBe('ngController');
358358
expect(div.controller('ngController')).toBe('ngController');
359-
expect(div.controller('other')).toBe(undefined);
359+
expect(div.controller('other')).toBeUndefined();
360360

361361
dealoc(div);
362362
});

test/ng/compileSpec.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -3499,11 +3499,11 @@ describe('$compile', function() {
34993499
expect(element.attr('ng-my-attr')).toEqual('value');
35003500

35013501
attr.$set('ngMyAttr', undefined);
3502-
expect(element.attr('ng-my-attr')).toBe(undefined);
3502+
expect(element.attr('ng-my-attr')).toBeUndefined();
35033503

35043504
attr.$set('ngMyAttr', 'value');
35053505
attr.$set('ngMyAttr', null);
3506-
expect(element.attr('ng-my-attr')).toBe(undefined);
3506+
expect(element.attr('ng-my-attr')).toBeUndefined();
35073507
});
35083508

35093509

@@ -3988,7 +3988,7 @@ describe('$compile', function() {
39883988
describe('object reference', function() {
39893989
it('should update local when origin changes', inject(function() {
39903990
compile('<div><span my-component ref="name">');
3991-
expect(componentScope.ref).toBe(undefined);
3991+
expect(componentScope.ref).toBeUndefined();
39923992
expect(componentScope.refAlias).toBe(componentScope.ref);
39933993

39943994
$rootScope.name = 'misko';
@@ -4151,7 +4151,7 @@ describe('$compile', function() {
41514151
describe('optional object reference', function() {
41524152
it('should update local when origin changes', inject(function() {
41534153
compile('<div><span my-component optref="name">');
4154-
expect(componentScope.optRef).toBe(undefined);
4154+
expect(componentScope.optRef).toBeUndefined();
41554155
expect(componentScope.optRefAlias).toBe(componentScope.optRef);
41564156

41574157
$rootScope.name = 'misko';
@@ -4168,9 +4168,9 @@ describe('$compile', function() {
41684168
it('should not throw exception when reference does not exist', inject(function() {
41694169
compile('<div><span my-component>');
41704170

4171-
expect(componentScope.optref).toBe(undefined);
4172-
expect(componentScope.optrefAlias).toBe(undefined);
4173-
expect(componentScope.optreference).toBe(undefined);
4171+
expect(componentScope.optref).toBeUndefined();
4172+
expect(componentScope.optrefAlias).toBeUndefined();
4173+
expect(componentScope.optreference).toBeUndefined();
41744174
}));
41754175
});
41764176

@@ -4225,7 +4225,7 @@ describe('$compile', function() {
42254225
describe('one-way binding', function() {
42264226
it('should update isolate when the identity of origin changes', inject(function() {
42274227
compile('<div><span my-component ow-ref="obj">');
4228-
expect(componentScope.owRef).toBe(undefined);
4228+
expect(componentScope.owRef).toBeUndefined();
42294229
expect(componentScope.owRefAlias).toBe(componentScope.owRef);
42304230

42314231
$rootScope.obj = {value: 'initial'};
@@ -4457,7 +4457,7 @@ describe('$compile', function() {
44574457
describe('optional one-way binding', function() {
44584458
it('should update local when origin changes', inject(function() {
44594459
compile('<div><span my-component ow-optref="name">');
4460-
expect(componentScope.owOptref).toBe(undefined);
4460+
expect(componentScope.owOptref).toBeUndefined();
44614461
expect(componentScope.owOptrefAlias).toBe(componentScope.owOptref);
44624462

44634463
$rootScope.name = 'misko';
@@ -4474,8 +4474,8 @@ describe('$compile', function() {
44744474
it('should not throw exception when reference does not exist', inject(function() {
44754475
compile('<div><span my-component>');
44764476

4477-
expect(componentScope.owOptref).toBe(undefined);
4478-
expect(componentScope.owOptrefAlias).toBe(undefined);
4477+
expect(componentScope.owOptref).toBeUndefined();
4478+
expect(componentScope.owOptrefAlias).toBeUndefined();
44794479
}));
44804480
});
44814481
});

test/ng/directive/inputSpec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ describe('input', function() {
161161

162162
helper.attrs.$set('placeholder', undefined);
163163
msie && browserTrigger(inputElm, 'input');
164-
expect(inputElm.attr('placeholder')).toBe(undefined);
164+
expect(inputElm.attr('placeholder')).toBeUndefined();
165165
expect(inputElm).toBePristine();
166166

167167
helper.changeInputValueTo('foo');

test/ng/directive/ngModelSpec.js

+21-21
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ describe('ngModel', function() {
117117
expect(ctrl.$invalid).toBe(true);
118118

119119
ctrl.$setValidity('third', undefined);
120-
expect(ctrl.$valid).toBe(undefined);
121-
expect(ctrl.$invalid).toBe(undefined);
120+
expect(ctrl.$valid).toBeUndefined();
121+
expect(ctrl.$invalid).toBeUndefined();
122122

123123
ctrl.$setValidity('third', null);
124124
expect(ctrl.$valid).toBe(false);
@@ -1001,15 +1001,15 @@ describe('ngModel', function() {
10011001

10021002
scope.$apply('value = "123"');
10031003
expect(ctrl.$pending).toEqual({async: true});
1004-
expect(ctrl.$valid).toBe(undefined);
1005-
expect(ctrl.$invalid).toBe(undefined);
1004+
expect(ctrl.$valid).toBeUndefined();
1005+
expect(ctrl.$invalid).toBeUndefined();
10061006
expect(defers.length).toBe(1);
10071007
expect(isObject(ctrl.$pending)).toBe(true);
10081008

10091009
scope.$apply('value = "456"');
10101010
expect(ctrl.$pending).toEqual({async: true});
1011-
expect(ctrl.$valid).toBe(undefined);
1012-
expect(ctrl.$invalid).toBe(undefined);
1011+
expect(ctrl.$valid).toBeUndefined();
1012+
expect(ctrl.$invalid).toBeUndefined();
10131013
expect(defers.length).toBe(2);
10141014
expect(isObject(ctrl.$pending)).toBe(true);
10151015

@@ -1034,8 +1034,8 @@ describe('ngModel', function() {
10341034
};
10351035

10361036
ctrl.$setViewValue('x..y..z');
1037-
expect(ctrl.$valid).toBe(undefined);
1038-
expect(ctrl.$invalid).toBe(undefined);
1037+
expect(ctrl.$valid).toBeUndefined();
1038+
expect(ctrl.$invalid).toBeUndefined();
10391039

10401040
failParser = true;
10411041

@@ -1145,8 +1145,8 @@ describe('ngModel', function() {
11451145
$rootScope.$digest();
11461146

11471147
expect(formCtrl.$pending.usernameAvailability).toBeTruthy();
1148-
expect(usernameCtrl.$invalid).toBe(undefined);
1149-
expect(formCtrl.$invalid).toBe(undefined);
1148+
expect(usernameCtrl.$invalid).toBeUndefined();
1149+
expect(formCtrl.$invalid).toBeUndefined();
11501150

11511151
usernameDefer.resolve();
11521152
$rootScope.$digest();
@@ -1892,7 +1892,7 @@ describe('ngModelOptions attributes', function() {
18921892
'/>');
18931893

18941894
browserTrigger(inputElm, 'click');
1895-
expect($rootScope.checkbox).toBe(undefined);
1895+
expect($rootScope.checkbox).toBeUndefined();
18961896

18971897
browserTrigger(inputElm, 'blur');
18981898
expect($rootScope.checkbox).toBe(true);
@@ -1980,9 +1980,9 @@ describe('ngModelOptions attributes', function() {
19801980
'/>');
19811981

19821982
browserTrigger(inputElm, 'click');
1983-
expect($rootScope.checkbox).toBe(undefined);
1983+
expect($rootScope.checkbox).toBeUndefined();
19841984
$timeout.flush(2000);
1985-
expect($rootScope.checkbox).toBe(undefined);
1985+
expect($rootScope.checkbox).toBeUndefined();
19861986
$timeout.flush(9000);
19871987
expect($rootScope.checkbox).toBe(true);
19881988
});
@@ -2038,9 +2038,9 @@ describe('ngModelOptions attributes', function() {
20382038
'/>');
20392039

20402040
helper.changeInputValueTo('a');
2041-
expect($rootScope.checkbox).toBe(undefined);
2041+
expect($rootScope.checkbox).toBeUndefined();
20422042
$timeout.flush(6000);
2043-
expect($rootScope.checkbox).toBe(undefined);
2043+
expect($rootScope.checkbox).toBeUndefined();
20442044
$timeout.flush(4000);
20452045
expect($rootScope.name).toEqual('a');
20462046
helper.changeInputValueTo('b');
@@ -2060,9 +2060,9 @@ describe('ngModelOptions attributes', function() {
20602060

20612061
inputElm[0].checked = false;
20622062
browserTrigger(inputElm, 'click');
2063-
expect($rootScope.checkbox).toBe(undefined);
2063+
expect($rootScope.checkbox).toBeUndefined();
20642064
$timeout.flush(8000);
2065-
expect($rootScope.checkbox).toBe(undefined);
2065+
expect($rootScope.checkbox).toBeUndefined();
20662066
$timeout.flush(3000);
20672067
expect($rootScope.checkbox).toBe(true);
20682068
inputElm[0].checked = true;
@@ -2083,9 +2083,9 @@ describe('ngModelOptions attributes', function() {
20832083

20842084
inputElm[0].checked = false;
20852085
browserTrigger(inputElm, 'click');
2086-
expect($rootScope.checkbox).toBe(undefined);
2086+
expect($rootScope.checkbox).toBeUndefined();
20872087
$timeout.flush(8000);
2088-
expect($rootScope.checkbox).toBe(undefined);
2088+
expect($rootScope.checkbox).toBeUndefined();
20892089
$timeout.flush(3000);
20902090
expect($rootScope.checkbox).toBe(true);
20912091
inputElm[0].checked = true;
@@ -2108,9 +2108,9 @@ describe('ngModelOptions attributes', function() {
21082108
helper.changeGivenInputTo(inputElm, 'a');
21092109
expect($rootScope.name).toEqual(undefined);
21102110
browserTrigger(inputElm, 'blur');
2111-
expect($rootScope.name).toBe(undefined);
2111+
expect($rootScope.name).toBeUndefined();
21122112
$timeout.flush(2000);
2113-
expect($rootScope.name).toBe(undefined);
2113+
expect($rootScope.name).toBeUndefined();
21142114
$timeout.flush(9000);
21152115
expect($rootScope.name).toEqual('a');
21162116
dealoc(doc);

test/ng/directive/ngSrcSpec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe('ngSrc', function() {
1414
element = $compile('<img ng-src="{{image.url}}">')($rootScope);
1515
$rootScope.$digest();
1616
expect(element.attr('src')).not.toBe('');
17-
expect(element.attr('src')).toBe(undefined);
17+
expect(element.attr('src')).toBeUndefined();
1818
}));
1919

2020
it('should sanitize url', inject(function($rootScope, $compile) {

test/ng/filter/filtersSpec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ describe('filters', function() {
161161
});
162162

163163
it('should pass through null and undefined to be compatible with one-time binding', function() {
164-
expect(currency(undefined)).toBe(undefined);
164+
expect(currency(undefined)).toBeUndefined();
165165
expect(currency(null)).toBe(null);
166166
});
167167

@@ -233,7 +233,7 @@ describe('filters', function() {
233233

234234
it('should pass through null and undefined to be compatible with one-time binding', function() {
235235
expect(number(null)).toBe(null);
236-
expect(number(undefined)).toBe(undefined);
236+
expect(number(undefined)).toBeUndefined();
237237
});
238238

239239
it('should filter exponentially large numbers', function() {

test/ng/httpSpec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1413,7 +1413,7 @@ describe('$http', function() {
14131413
$httpBackend.flush();
14141414

14151415
expect(callback.callCount).toBe(3);
1416-
expect(callback.calls[0].args[0]).toBe(undefined);
1416+
expect(callback.calls[0].args[0]).toBeUndefined();
14171417
expect(callback.calls[1].args[0]).toBe(null);
14181418
expect(callback.calls[2].args[0]).toBe('');
14191419
});

test/ng/parseSpec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1914,7 +1914,7 @@ describe('parser', function() {
19141914
expect(scope.$eval('a.b.c.d')).toBeUndefined();
19151915
scope.a = undefined;
19161916
expect(scope.$eval('a - b')).toBe(0);
1917-
expect(scope.$eval('a + b')).toBe(undefined);
1917+
expect(scope.$eval('a + b')).toBeUndefined();
19181918
scope.a = 0;
19191919
expect(scope.$eval('a - b')).toBe(0);
19201920
expect(scope.$eval('a + b')).toBe(0);

test/ng/sceSpecs.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ describe('SCE', function() {
122122
}));
123123

124124
it('should wrap undefined into undefined', inject(function($sce) {
125-
expect($sce.trustAsHtml(undefined)).toBe(undefined);
125+
expect($sce.trustAsHtml(undefined)).toBeUndefined();
126126
}));
127127

128128
it('should unwrap undefined into undefined', inject(function($sce) {
129-
expect($sce.getTrusted($sce.HTML, undefined)).toBe(undefined);
129+
expect($sce.getTrusted($sce.HTML, undefined)).toBeUndefined();
130130
}));
131131

132132
it('should wrap null into null', inject(function($sce) {
@@ -207,7 +207,7 @@ describe('SCE', function() {
207207
expect($sce.parseAsJs('true')()).toBe(true);
208208
expect($sce.parseAsJs('false')()).toBe(false);
209209
expect($sce.parseAsJs('null')()).toBe(null);
210-
expect($sce.parseAsJs('undefined')()).toBe(undefined);
210+
expect($sce.parseAsJs('undefined')()).toBeUndefined();
211211
expect($sce.parseAsJs('"string"')()).toBe("string");
212212
}));
213213

test/ng/snifferSpec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ describe('$sniffer', function() {
122122
describe('animations', function() {
123123
it('should be either true or false', function() {
124124
inject(function($sniffer) {
125-
expect($sniffer.animations).not.toBe(undefined);
125+
expect($sniffer.animations).not.toBeUndefined();
126126
});
127127
});
128128

@@ -218,7 +218,7 @@ describe('$sniffer', function() {
218218

219219
it('should be either true or false', function() {
220220
inject(function($sniffer) {
221-
expect($sniffer.transitions).not.toBe(undefined);
221+
expect($sniffer.transitions).not.toBeUndefined();
222222
});
223223
});
224224

test/ngAria/ariaSpec.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ describe('$aria', function() {
250250

251251
it('should not add a role to a native checkbox', function() {
252252
compileElement('<input type="checkbox" ng-model="val"/>');
253-
expect(element.attr('role')).toBe(undefined);
253+
expect(element.attr('role')).toBeUndefined();
254254
});
255255

256256
it('should add missing role="radio" to custom input', function() {
@@ -260,7 +260,7 @@ describe('$aria', function() {
260260

261261
it('should not add a role to a native radio button', function() {
262262
compileElement('<input type="radio" ng-model="val"/>');
263-
expect(element.attr('role')).toBe(undefined);
263+
expect(element.attr('role')).toBeUndefined();
264264
});
265265

266266
it('should add missing role="slider" to custom input', function() {
@@ -270,7 +270,7 @@ describe('$aria', function() {
270270

271271
it('should not add a role to a native range input', function() {
272272
compileElement('<input type="range" ng-model="val"/>');
273-
expect(element.attr('role')).toBe(undefined);
273+
expect(element.attr('role')).toBeUndefined();
274274
});
275275
});
276276

test/ngResource/resourceSpec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ describe("basic usage", function() {
8181
});
8282

8383
it('should skip over null/undefined members', function() {
84-
expect(lookupDottedPath(data, 'a.b.c')).toBe(undefined);
85-
expect(lookupDottedPath(data, 'a.c.c')).toBe(undefined);
86-
expect(lookupDottedPath(data, 'a.b.c.d')).toBe(undefined);
87-
expect(lookupDottedPath(data, 'NOT_EXIST')).toBe(undefined);
84+
expect(lookupDottedPath(data, 'a.b.c')).toBeUndefined();
85+
expect(lookupDottedPath(data, 'a.c.c')).toBeUndefined();
86+
expect(lookupDottedPath(data, 'a.b.c.d')).toBeUndefined();
87+
expect(lookupDottedPath(data, 'NOT_EXIST')).toBeUndefined();
8888
});
8989
});
9090

0 commit comments

Comments
 (0)