refactor(*): use the toThrowMinErr() matcher when possible

This commit is contained in:
Georgios Kalpakas
2016-10-05 17:18:09 +03:00
parent b54a39e202
commit fbf30b28e0
4 changed files with 11 additions and 14 deletions
+7 -10
View File
@@ -1636,8 +1636,8 @@ describe('angular', function() {
expect(function() {
angularInit(appElement, angular.bootstrap);
}).toThrowError(
new RegExp('\\[\\$injector:modulerr] Failed to instantiate module doesntexist due to:\\n' +
}).toThrowMinErr('$injector', 'modulerr',
new RegExp('Failed to instantiate module doesntexist due to:\\n' +
'.*\\[\\$injector:nomod] Module \'doesntexist\' is not available! You either ' +
'misspelled the module name or forgot to load it\\.')
);
@@ -1650,9 +1650,8 @@ describe('angular', function() {
expect(function() {
angular.bootstrap(element);
}).toThrowError(
/\[ng:btstrpd\] App Already Bootstrapped with this Element '<div class="?ng\-scope"?( ng[0-9]+="?[0-9]+"?)?>'/i
);
}).toThrowMinErr('ng', 'btstrpd',
/App Already Bootstrapped with this Element '<div class="?ng-scope"?( ng\d+="?\d+"?)?>'/i);
dealoc(element);
});
@@ -1662,9 +1661,7 @@ describe('angular', function() {
angular.bootstrap(document.getElementsByTagName('html')[0]);
expect(function() {
angular.bootstrap(document);
}).toThrowError(
/\[ng:btstrpd\] App Already Bootstrapped with this Element 'document'/i
);
}).toThrowMinErr('ng', 'btstrpd', /App Already Bootstrapped with this Element 'document'/i);
dealoc(document);
});
@@ -1863,8 +1860,8 @@ describe('angular', function() {
expect(function() {
angular.bootstrap(element, ['doesntexist']);
}).toThrowError(
new RegExp('\\[\\$injector:modulerr\\] Failed to instantiate module doesntexist due to:\\n' +
}).toThrowMinErr('$injector', 'modulerr',
new RegExp('Failed to instantiate module doesntexist due to:\\n' +
'.*\\[\\$injector:nomod\\] Module \'doesntexist\' is not available! You either ' +
'misspelled the module name or forgot to load it\\.'));
+1 -1
View File
@@ -1062,7 +1062,7 @@ describe('injector', function() {
createInjector([function($provide) {
$provide.value('name', 'angular');
}, instanceLookupInModule]);
}).toThrowError(/\[\$injector:unpr] Unknown provider: name/);
}).toThrowMinErr('$injector', 'modulerr', '[$injector:unpr] Unknown provider: name');
});
});
});
+1 -1
View File
@@ -1712,7 +1712,7 @@ describe('jqLite', function() {
aElem.on('click', noop);
expect(function() {
aElem.off('click', noop, '.test');
}).toThrowError(/\[jqLite:offargs\]/);
}).toThrowMinErr('jqLite', 'offargs');
});
});
+2 -2
View File
@@ -136,7 +136,7 @@ describe('validators', function() {
expect(function() {
var inputElm = helper.compileInput('<input type="text" ng-model="foo" ng-pattern="fooRegexp" />');
$rootScope.$apply('foo = \'bar\'');
}).not.toThrowError(/^\[ngPattern:noregexp\] Expected fooRegexp to be a RegExp but was/);
}).not.toThrow();
});
@@ -147,7 +147,7 @@ describe('validators', function() {
$rootScope.fooRegexp = {};
$rootScope.foo = 'bar';
});
}).toThrowError(/^\[ngPattern:noregexp\] Expected fooRegexp to be a RegExp but was/);
}).toThrowMinErr('ngPattern', 'noregexp', 'Expected fooRegexp to be a RegExp but was');
});