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

Commit fbf30b2

Browse files
committed
refactor(*): use the toThrowMinErr() matcher when possible
1 parent b54a39e commit fbf30b2

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
@@ -1636,8 +1636,8 @@ describe('angular', function() {
16361636

16371637
expect(function() {
16381638
angularInit(appElement, angular.bootstrap);
1639-
}).toThrowError(
1640-
new RegExp('\\[\\$injector:modulerr] Failed to instantiate module doesntexist due to:\\n' +
1639+
}).toThrowMinErr('$injector', 'modulerr',
1640+
new RegExp('Failed to instantiate module doesntexist due to:\\n' +
16411641
'.*\\[\\$injector:nomod] Module \'doesntexist\' is not available! You either ' +
16421642
'misspelled the module name or forgot to load it\\.')
16431643
);
@@ -1650,9 +1650,8 @@ describe('angular', function() {
16501650

16511651
expect(function() {
16521652
angular.bootstrap(element);
1653-
}).toThrowError(
1654-
/\[ng:btstrpd\] App Already Bootstrapped with this Element '<div class="?ng\-scope"?( ng[0-9]+="?[0-9]+"?)?>'/i
1655-
);
1653+
}).toThrowMinErr('ng', 'btstrpd',
1654+
/App Already Bootstrapped with this Element '<div class="?ng-scope"?( ng\d+="?\d+"?)?>'/i);
16561655

16571656
dealoc(element);
16581657
});
@@ -1662,9 +1661,7 @@ describe('angular', function() {
16621661
angular.bootstrap(document.getElementsByTagName('html')[0]);
16631662
expect(function() {
16641663
angular.bootstrap(document);
1665-
}).toThrowError(
1666-
/\[ng:btstrpd\] App Already Bootstrapped with this Element 'document'/i
1667-
);
1664+
}).toThrowMinErr('ng', 'btstrpd', /App Already Bootstrapped with this Element 'document'/i);
16681665

16691666
dealoc(document);
16701667
});
@@ -1863,8 +1860,8 @@ describe('angular', function() {
18631860

18641861
expect(function() {
18651862
angular.bootstrap(element, ['doesntexist']);
1866-
}).toThrowError(
1867-
new RegExp('\\[\\$injector:modulerr\\] Failed to instantiate module doesntexist due to:\\n' +
1863+
}).toThrowMinErr('$injector', 'modulerr',
1864+
new RegExp('Failed to instantiate module doesntexist due to:\\n' +
18681865
'.*\\[\\$injector:nomod\\] Module \'doesntexist\' is not available! You either ' +
18691866
'misspelled the module name or forgot to load it\\.'));
18701867

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
@@ -1712,7 +1712,7 @@ describe('jqLite', function() {
17121712
aElem.on('click', noop);
17131713
expect(function() {
17141714
aElem.off('click', noop, '.test');
1715-
}).toThrowError(/\[jqLite:offargs\]/);
1715+
}).toThrowMinErr('jqLite', 'offargs');
17161716
});
17171717
});
17181718

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)