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

Commit 9efe842

Browse files
gkalpakpetebacondarwin
authored andcommitted
refactor(*): use the toThrowMinErr() matcher when possible
1 parent feede20 commit 9efe842

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

test/AngularSpec.js

+7-10
Original file line numberDiff line numberDiff line change
@@ -1650,8 +1650,8 @@ describe('angular', function() {
16501650

16511651
expect(function() {
16521652
angularInit(appElement, angular.bootstrap);
1653-
}).toThrowError(
1654-
new RegExp('\\[\\$injector:modulerr] Failed to instantiate module doesntexist due to:\\n' +
1653+
}).toThrowMinErr('$injector', 'modulerr',
1654+
new RegExp('Failed to instantiate module doesntexist due to:\\n' +
16551655
'.*\\[\\$injector:nomod] Module \'doesntexist\' is not available! You either ' +
16561656
'misspelled the module name or forgot to load it\\.')
16571657
);
@@ -1664,9 +1664,8 @@ describe('angular', function() {
16641664

16651665
expect(function() {
16661666
angular.bootstrap(element);
1667-
}).toThrowError(
1668-
/\[ng:btstrpd\] App Already Bootstrapped with this Element '<div class="?ng\-scope"?( ng[0-9]+="?[0-9]+"?)?>'/i
1669-
);
1667+
}).toThrowMinErr('ng', 'btstrpd',
1668+
/App Already Bootstrapped with this Element '<div class="?ng-scope"?( ng\d+="?\d+"?)?>'/i);
16701669

16711670
dealoc(element);
16721671
});
@@ -1676,9 +1675,7 @@ describe('angular', function() {
16761675
angular.bootstrap(document.getElementsByTagName('html')[0]);
16771676
expect(function() {
16781677
angular.bootstrap(document);
1679-
}).toThrowError(
1680-
/\[ng:btstrpd\] App Already Bootstrapped with this Element 'document'/i
1681-
);
1678+
}).toThrowMinErr('ng', 'btstrpd', /App Already Bootstrapped with this Element 'document'/i);
16821679

16831680
dealoc(document);
16841681
});
@@ -1898,8 +1895,8 @@ describe('angular', function() {
18981895

18991896
expect(function() {
19001897
angular.bootstrap(element, ['doesntexist']);
1901-
}).toThrowError(
1902-
new RegExp('\\[\\$injector:modulerr\\] Failed to instantiate module doesntexist due to:\\n' +
1898+
}).toThrowMinErr('$injector', 'modulerr',
1899+
new RegExp('Failed to instantiate module doesntexist due to:\\n' +
19031900
'.*\\[\\$injector:nomod\\] Module \'doesntexist\' is not available! You either ' +
19041901
'misspelled the module name or forgot to load it\\.'));
19051902

test/auto/injectorSpec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,7 @@ describe('injector', function() {
10621062
createInjector([function($provide) {
10631063
$provide.value('name', 'angular');
10641064
}, instanceLookupInModule]);
1065-
}).toThrowError(/\[\$injector:unpr] Unknown provider: name/);
1065+
}).toThrowMinErr('$injector', 'modulerr', '[$injector:unpr] Unknown provider: name');
10661066
});
10671067
});
10681068
});

test/jqLiteSpec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1687,7 +1687,7 @@ describe('jqLite', function() {
16871687
aElem.on('click', noop);
16881688
expect(function() {
16891689
aElem.off('click', noop, '.test');
1690-
}).toThrowError(/\[jqLite:offargs\]/);
1690+
}).toThrowMinErr('jqLite', 'offargs');
16911691
});
16921692
});
16931693

test/ng/directive/validatorsSpec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ describe('validators', function() {
136136
expect(function() {
137137
var inputElm = helper.compileInput('<input type="text" ng-model="foo" ng-pattern="fooRegexp" />');
138138
$rootScope.$apply('foo = \'bar\'');
139-
}).not.toThrowError(/^\[ngPattern:noregexp\] Expected fooRegexp to be a RegExp but was/);
139+
}).not.toThrow();
140140
});
141141

142142

@@ -147,7 +147,7 @@ describe('validators', function() {
147147
$rootScope.fooRegexp = {};
148148
$rootScope.foo = 'bar';
149149
});
150-
}).toThrowError(/^\[ngPattern:noregexp\] Expected fooRegexp to be a RegExp but was/);
150+
}).toThrowMinErr('ngPattern', 'noregexp', 'Expected fooRegexp to be a RegExp but was');
151151
});
152152

153153

0 commit comments

Comments
 (0)