Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 93b26ed

Browse files
m-amrpetebacondarwin
authored andcommitted
refactor(*): use toBeUndefined consistently
Closes #14185 Fixes #14184
1 parent 63581a2 commit 93b26ed

File tree

18 files changed

+59
-59
lines changed

18 files changed

+59
-59
lines changed

docs/content/guide/unit-testing.ngdoc

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3498,11 +3498,11 @@ describe('$compile', function() {
34983498
expect(element.attr('ng-my-attr')).toEqual('value');
34993499

35003500
attr.$set('ngMyAttr', undefined);
3501-
expect(element.attr('ng-my-attr')).toBe(undefined);
3501+
expect(element.attr('ng-my-attr')).toBeUndefined();
35023502

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

35083508

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

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

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

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

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

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

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

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

test/ng/directive/inputSpec.js

Lines changed: 1 addition & 1 deletion
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

Lines changed: 21 additions & 21 deletions
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

Lines changed: 1 addition & 1 deletion
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) {

0 commit comments

Comments
 (0)