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

Commit a17ef89

Browse files
committed
fixup! test(*): introduce the toEqualMinErr() custom Jasmine matcher
1 parent f7c5643 commit a17ef89

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

test/ng/compileSpec.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -4630,7 +4630,8 @@ describe('$compile', function() {
46304630
// Update val to trigger the unstable onChanges, which will result in an error
46314631
$rootScope.$apply('a = 42');
46324632
expect($exceptionHandler.errors.length).toEqual(1);
4633-
expect($exceptionHandler.errors[0].toString()).toContain('[$compile:infchng] 10 $onChanges() iterations reached.');
4633+
expect($exceptionHandler.errors[0]).
4634+
toEqualMinErr('$compile', 'infchng', '10 $onChanges() iterations reached.');
46344635
});
46354636
});
46364637

test/ng/httpSpec.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,7 @@ describe('$http', function() {
10451045
$http({method: 'JSONP', url: 'http://example.org/path'})
10461046
.catch(function(e) { error = e; });
10471047
$rootScope.$digest();
1048-
expect(error.message).toContain('[$sce:insecurl]');
1048+
expect(error).toEqualMinErr('$sce', 'insecurl');
10491049
});
10501050

10511051
it('should accept an explicitly trusted resource url', function() {
@@ -1066,41 +1066,41 @@ describe('$http', function() {
10661066
$http({ method: 'JSONP', url: $sce.trustAsResourceUrl('http://example.org/path?callback=JSON_CALLBACK')})
10671067
.catch(function(e) { error = e; });
10681068
$rootScope.$digest();
1069-
expect(error.message).toContain('[$http:badjsonp]');
1069+
expect(error).toEqualMinErr('$http', 'badjsonp');
10701070

10711071
error = undefined;
10721072
$http({ method: 'JSONP', url: $sce.trustAsResourceUrl('http://example.org/path?other=JSON_CALLBACK')})
10731073
.catch(function(e) { error = e; });
10741074
$rootScope.$digest();
1075-
expect(error.message).toContain('[$http:badjsonp]');
1075+
expect(error).toEqualMinErr('$http', 'badjsonp');
10761076
});
10771077

10781078
it('should error if a param contains a JSON_CALLBACK value', function() {
10791079
var error;
10801080
$http({ method: 'JSONP', url: $sce.trustAsResourceUrl('http://example.org/path'), params: {callback: 'JSON_CALLBACK'}})
10811081
.catch(function(e) { error = e; });
10821082
$rootScope.$digest();
1083-
expect(error.message).toContain('[$http:badjsonp]');
1083+
expect(error).toEqualMinErr('$http', 'badjsonp');
10841084

10851085
error = undefined;
10861086
$http({ method: 'JSONP', url: $sce.trustAsResourceUrl('http://example.org/path'), params: {other: 'JSON_CALLBACK'}})
10871087
.catch(function(e) { error = e; });
10881088
$rootScope.$digest();
1089-
expect(error.message).toContain('[$http:badjsonp]');
1089+
expect(error).toEqualMinErr('$http', 'badjsonp');
10901090
});
10911091

10921092
it('should error if there is already a param matching the jsonpCallbackParam key', function() {
10931093
var error;
10941094
$http({ method: 'JSONP', url: $sce.trustAsResourceUrl('http://example.org/path'), params: {callback: 'evilThing'}})
10951095
.catch(function(e) { error = e; });
10961096
$rootScope.$digest();
1097-
expect(error.message).toContain('[$http:badjsonp]');
1097+
expect(error).toEqualMinErr('$http', 'badjsonp');
10981098

10991099
error = undefined;
11001100
$http({ method: 'JSONP', jsonpCallbackParam: 'cb', url: $sce.trustAsResourceUrl('http://example.org/path'), params: {cb: 'evilThing'}})
11011101
.catch(function(e) { error = e; });
11021102
$rootScope.$digest();
1103-
expect(error.message).toContain('[$http:badjsonp]');
1103+
expect(error).toEqualMinErr('$http', 'badjsonp');
11041104
});
11051105
});
11061106

test/ngRoute/routeSpec.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,8 @@ describe('$route', function() {
891891
$rootScope.$digest();
892892

893893
$httpBackend.flush();
894-
expect($exceptionHandler.errors.pop().message).toContain('[$compile:tpload] Failed to load template: r1.html');
894+
expect($exceptionHandler.errors.pop()).
895+
toEqualMinErr('$compile', 'tpload', 'Failed to load template: r1.html');
895896

896897
$httpBackend.expectGET('r2.html').respond('');
897898
$location.path('/r2');

0 commit comments

Comments
 (0)