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

refactor(*): use toBeUndefined function instead of tobe(undefined) fu… #14185

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/content/guide/unit-testing.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ describe("Deep Thought", function() {
beforeAll(module("UltimateQuestion"));

beforeAll(inject(function(DeepThought) {
expect(DeepThought.answer).toBe(undefined);
expect(DeepThought.answer).toBeUndefined();
DeepThought.generateAnswer();
}));

Expand Down
2 changes: 1 addition & 1 deletion i18n/spec/closureI18nExtractorSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ describe("serializeContent", function() {
it("should not transform arrays into objects", function() {
var serializedContent = closureI18nExtractor.serializeContent(newTestLocaleInfo().fr_CA);
var deserializedLocale = eval("(" + serializedContent + ")");
expect(deserializedLocale.DATETIME_FORMATS.MONTH.length).not.toBe(undefined);
expect(deserializedLocale.DATETIME_FORMATS.MONTH.length).not.toBeUndefined();
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/ngMock/angular-mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2670,7 +2670,7 @@ angular.mock.$RootScopeDecorator = ['$delegate', function($delegate) {
* beforeAll(module("UltimateQuestion"));
*
* beforeAll(inject(function(DeepThought) {
* expect(DeepThought.answer).toBe(undefined);
* expect(DeepThought.answer).toBeUndefined();
* DeepThought.generateAnswer();
* }));
*
Expand Down
2 changes: 1 addition & 1 deletion test/AngularSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ describe('angular', function() {
});

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

it('should return empty string when jq is enabled manually via [ng-jq] with empty string', function() {
Expand Down
6 changes: 3 additions & 3 deletions test/ApiSpecs.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ describe('api', function() {
map.put(key, value1);
map.put(key, value2);
expect(map.get(key)).toBe(value2);
expect(map.get({})).toBe(undefined);
expect(map.get({})).toBeUndefined();
expect(map.remove(key)).toBe(value2);
expect(map.get(key)).toBe(undefined);
expect(map.get(key)).toBeUndefined();
});

it('should init from an array', function() {
var map = new HashMap(['a','b']);
expect(map.get('a')).toBe(0);
expect(map.get('b')).toBe(1);
expect(map.get('c')).toBe(undefined);
expect(map.get('c')).toBeUndefined();
});

it('should maintain hashKey for object keys', function() {
Expand Down
2 changes: 1 addition & 1 deletion test/jqLiteSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ describe('jqLite', function() {

expect(div.controller()).toBe('ngController');
expect(div.controller('ngController')).toBe('ngController');
expect(div.controller('other')).toBe(undefined);
expect(div.controller('other')).toBeUndefined();

dealoc(div);
});
Expand Down
22 changes: 11 additions & 11 deletions test/ng/compileSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3499,11 +3499,11 @@ describe('$compile', function() {
expect(element.attr('ng-my-attr')).toEqual('value');

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

attr.$set('ngMyAttr', 'value');
attr.$set('ngMyAttr', null);
expect(element.attr('ng-my-attr')).toBe(undefined);
expect(element.attr('ng-my-attr')).toBeUndefined();
});


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

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

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

expect(componentScope.optref).toBe(undefined);
expect(componentScope.optrefAlias).toBe(undefined);
expect(componentScope.optreference).toBe(undefined);
expect(componentScope.optref).toBeUndefined();
expect(componentScope.optrefAlias).toBeUndefined();
expect(componentScope.optreference).toBeUndefined();
}));
});

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

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

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

expect(componentScope.owOptref).toBe(undefined);
expect(componentScope.owOptrefAlias).toBe(undefined);
expect(componentScope.owOptref).toBeUndefined();
expect(componentScope.owOptrefAlias).toBeUndefined();
}));
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/ng/directive/inputSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ describe('input', function() {

helper.attrs.$set('placeholder', undefined);
msie && browserTrigger(inputElm, 'input');
expect(inputElm.attr('placeholder')).toBe(undefined);
expect(inputElm.attr('placeholder')).toBeUndefined();
expect(inputElm).toBePristine();

helper.changeInputValueTo('foo');
Expand Down
42 changes: 21 additions & 21 deletions test/ng/directive/ngModelSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ describe('ngModel', function() {
expect(ctrl.$invalid).toBe(true);

ctrl.$setValidity('third', undefined);
expect(ctrl.$valid).toBe(undefined);
expect(ctrl.$invalid).toBe(undefined);
expect(ctrl.$valid).toBeUndefined();
expect(ctrl.$invalid).toBeUndefined();

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

scope.$apply('value = "123"');
expect(ctrl.$pending).toEqual({async: true});
expect(ctrl.$valid).toBe(undefined);
expect(ctrl.$invalid).toBe(undefined);
expect(ctrl.$valid).toBeUndefined();
expect(ctrl.$invalid).toBeUndefined();
expect(defers.length).toBe(1);
expect(isObject(ctrl.$pending)).toBe(true);

scope.$apply('value = "456"');
expect(ctrl.$pending).toEqual({async: true});
expect(ctrl.$valid).toBe(undefined);
expect(ctrl.$invalid).toBe(undefined);
expect(ctrl.$valid).toBeUndefined();
expect(ctrl.$invalid).toBeUndefined();
expect(defers.length).toBe(2);
expect(isObject(ctrl.$pending)).toBe(true);

Expand All @@ -1034,8 +1034,8 @@ describe('ngModel', function() {
};

ctrl.$setViewValue('x..y..z');
expect(ctrl.$valid).toBe(undefined);
expect(ctrl.$invalid).toBe(undefined);
expect(ctrl.$valid).toBeUndefined();
expect(ctrl.$invalid).toBeUndefined();

failParser = true;

Expand Down Expand Up @@ -1145,8 +1145,8 @@ describe('ngModel', function() {
$rootScope.$digest();

expect(formCtrl.$pending.usernameAvailability).toBeTruthy();
expect(usernameCtrl.$invalid).toBe(undefined);
expect(formCtrl.$invalid).toBe(undefined);
expect(usernameCtrl.$invalid).toBeUndefined();
expect(formCtrl.$invalid).toBeUndefined();

usernameDefer.resolve();
$rootScope.$digest();
Expand Down Expand Up @@ -1892,7 +1892,7 @@ describe('ngModelOptions attributes', function() {
'/>');

browserTrigger(inputElm, 'click');
expect($rootScope.checkbox).toBe(undefined);
expect($rootScope.checkbox).toBeUndefined();

browserTrigger(inputElm, 'blur');
expect($rootScope.checkbox).toBe(true);
Expand Down Expand Up @@ -1980,9 +1980,9 @@ describe('ngModelOptions attributes', function() {
'/>');

browserTrigger(inputElm, 'click');
expect($rootScope.checkbox).toBe(undefined);
expect($rootScope.checkbox).toBeUndefined();
$timeout.flush(2000);
expect($rootScope.checkbox).toBe(undefined);
expect($rootScope.checkbox).toBeUndefined();
$timeout.flush(9000);
expect($rootScope.checkbox).toBe(true);
});
Expand Down Expand Up @@ -2038,9 +2038,9 @@ describe('ngModelOptions attributes', function() {
'/>');

helper.changeInputValueTo('a');
expect($rootScope.checkbox).toBe(undefined);
expect($rootScope.checkbox).toBeUndefined();
$timeout.flush(6000);
expect($rootScope.checkbox).toBe(undefined);
expect($rootScope.checkbox).toBeUndefined();
$timeout.flush(4000);
expect($rootScope.name).toEqual('a');
helper.changeInputValueTo('b');
Expand All @@ -2060,9 +2060,9 @@ describe('ngModelOptions attributes', function() {

inputElm[0].checked = false;
browserTrigger(inputElm, 'click');
expect($rootScope.checkbox).toBe(undefined);
expect($rootScope.checkbox).toBeUndefined();
$timeout.flush(8000);
expect($rootScope.checkbox).toBe(undefined);
expect($rootScope.checkbox).toBeUndefined();
$timeout.flush(3000);
expect($rootScope.checkbox).toBe(true);
inputElm[0].checked = true;
Expand All @@ -2083,9 +2083,9 @@ describe('ngModelOptions attributes', function() {

inputElm[0].checked = false;
browserTrigger(inputElm, 'click');
expect($rootScope.checkbox).toBe(undefined);
expect($rootScope.checkbox).toBeUndefined();
$timeout.flush(8000);
expect($rootScope.checkbox).toBe(undefined);
expect($rootScope.checkbox).toBeUndefined();
$timeout.flush(3000);
expect($rootScope.checkbox).toBe(true);
inputElm[0].checked = true;
Expand All @@ -2108,9 +2108,9 @@ describe('ngModelOptions attributes', function() {
helper.changeGivenInputTo(inputElm, 'a');
expect($rootScope.name).toEqual(undefined);
browserTrigger(inputElm, 'blur');
expect($rootScope.name).toBe(undefined);
expect($rootScope.name).toBeUndefined();
$timeout.flush(2000);
expect($rootScope.name).toBe(undefined);
expect($rootScope.name).toBeUndefined();
$timeout.flush(9000);
expect($rootScope.name).toEqual('a');
dealoc(doc);
Expand Down
2 changes: 1 addition & 1 deletion test/ng/directive/ngSrcSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('ngSrc', function() {
element = $compile('<img ng-src="{{image.url}}">')($rootScope);
$rootScope.$digest();
expect(element.attr('src')).not.toBe('');
expect(element.attr('src')).toBe(undefined);
expect(element.attr('src')).toBeUndefined();
}));

it('should sanitize url', inject(function($rootScope, $compile) {
Expand Down
4 changes: 2 additions & 2 deletions test/ng/filter/filtersSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ describe('filters', function() {
});

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

Expand Down Expand Up @@ -233,7 +233,7 @@ describe('filters', function() {

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

it('should filter exponentially large numbers', function() {
Expand Down
2 changes: 1 addition & 1 deletion test/ng/httpSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1413,7 +1413,7 @@ describe('$http', function() {
$httpBackend.flush();

expect(callback.callCount).toBe(3);
expect(callback.calls[0].args[0]).toBe(undefined);
expect(callback.calls[0].args[0]).toBeUndefined();
expect(callback.calls[1].args[0]).toBe(null);
expect(callback.calls[2].args[0]).toBe('');
});
Expand Down
2 changes: 1 addition & 1 deletion test/ng/parseSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1914,7 +1914,7 @@ describe('parser', function() {
expect(scope.$eval('a.b.c.d')).toBeUndefined();
scope.a = undefined;
expect(scope.$eval('a - b')).toBe(0);
expect(scope.$eval('a + b')).toBe(undefined);
expect(scope.$eval('a + b')).toBeUndefined();
scope.a = 0;
expect(scope.$eval('a - b')).toBe(0);
expect(scope.$eval('a + b')).toBe(0);
Expand Down
6 changes: 3 additions & 3 deletions test/ng/sceSpecs.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ describe('SCE', function() {
}));

it('should wrap undefined into undefined', inject(function($sce) {
expect($sce.trustAsHtml(undefined)).toBe(undefined);
expect($sce.trustAsHtml(undefined)).toBeUndefined();
}));

it('should unwrap undefined into undefined', inject(function($sce) {
expect($sce.getTrusted($sce.HTML, undefined)).toBe(undefined);
expect($sce.getTrusted($sce.HTML, undefined)).toBeUndefined();
}));

it('should wrap null into null', inject(function($sce) {
Expand Down Expand Up @@ -207,7 +207,7 @@ describe('SCE', function() {
expect($sce.parseAsJs('true')()).toBe(true);
expect($sce.parseAsJs('false')()).toBe(false);
expect($sce.parseAsJs('null')()).toBe(null);
expect($sce.parseAsJs('undefined')()).toBe(undefined);
expect($sce.parseAsJs('undefined')()).toBeUndefined();
expect($sce.parseAsJs('"string"')()).toBe("string");
}));

Expand Down
4 changes: 2 additions & 2 deletions test/ng/snifferSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe('$sniffer', function() {
describe('animations', function() {
it('should be either true or false', function() {
inject(function($sniffer) {
expect($sniffer.animations).not.toBe(undefined);
expect($sniffer.animations).not.toBeUndefined();
});
});

Expand Down Expand Up @@ -218,7 +218,7 @@ describe('$sniffer', function() {

it('should be either true or false', function() {
inject(function($sniffer) {
expect($sniffer.transitions).not.toBe(undefined);
expect($sniffer.transitions).not.toBeUndefined();
});
});

Expand Down
6 changes: 3 additions & 3 deletions test/ngAria/ariaSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ describe('$aria', function() {

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

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

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

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

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

Expand Down
8 changes: 4 additions & 4 deletions test/ngResource/resourceSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ describe("basic usage", function() {
});

it('should skip over null/undefined members', function() {
expect(lookupDottedPath(data, 'a.b.c')).toBe(undefined);
expect(lookupDottedPath(data, 'a.c.c')).toBe(undefined);
expect(lookupDottedPath(data, 'a.b.c.d')).toBe(undefined);
expect(lookupDottedPath(data, 'NOT_EXIST')).toBe(undefined);
expect(lookupDottedPath(data, 'a.b.c')).toBeUndefined();
expect(lookupDottedPath(data, 'a.c.c')).toBeUndefined();
expect(lookupDottedPath(data, 'a.b.c.d')).toBeUndefined();
expect(lookupDottedPath(data, 'NOT_EXIST')).toBeUndefined();
});
});

Expand Down
Loading