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

fix(test): fixed toThrow usage #4032

Merged
merged 1 commit into from
Sep 17, 2013
Merged
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
15 changes: 10 additions & 5 deletions test/ng/directive/ngIncludeSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,16 @@ describe('ngInclude', function() {
}));


it('should NOT use untrusted expressions ', inject(putIntoCache('myUrl', '{{name}} text'),
it('should NOT use untrusted URL expressions ', inject(putIntoCache('myUrl', '{{name}} text'),
function($rootScope, $compile, $sce) {
element = jqLite('<ng:include src="url"></ng:include>');
jqLite(document.body).append(element);
element = $compile(element)($rootScope);
$rootScope.name = 'chirayu';
$rootScope.url = 'myUrl';
expect($rootScope.$digest).toThrow();
$rootScope.url = 'http://example.com/myUrl';
expect(function() { $rootScope.$digest(); }).toThrowMinErr(
'$sce', 'insecurl',
/Blocked loading resource from url not allowed by \$sceDelegate policy. URL: http:\/\/example.com\/myUrl.*/);
jqLite(document.body).html('');
}));

Expand All @@ -82,11 +84,14 @@ describe('ngInclude', function() {
jqLite(document.body).append(element);
element = $compile(element)($rootScope);
$rootScope.name = 'chirayu';
$rootScope.url = $sce.trustAsUrl('myUrl');
expect($rootScope.$digest).toThrow();
$rootScope.url = $sce.trustAsUrl('http://example.com/myUrl');
expect(function() { $rootScope.$digest(); }).toThrowMinErr(
'$sce', 'insecurl',
/Blocked loading resource from url not allowed by \$sceDelegate policy. URL: http:\/\/example.com\/myUrl.*/);
jqLite(document.body).html('');
}));


it('should remove previously included text if a falsy value is bound to src', inject(
putIntoCache('myUrl', '{{name}}'),
function($rootScope, $compile) {
Expand Down