aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorVojta Jina2012-04-10 16:50:31 -0700
committerVojta Jina2012-04-11 15:50:47 -0700
commit5bcd7198664dca2bf85ddf8b3a89f417cd4e4796 (patch)
tree3c9bde1e97e94a4af986019dbaea1eaa50a209d9 /test
parente1743cc837a51e3146f2e73e3083eee7f4a8f549 (diff)
downloadangular.js-5bcd7198664dca2bf85ddf8b3a89f417cd4e4796.tar.bz2
chore(ngSanitize): extract $sanitize, ngBindHtml, linkyFilter into a module
Create build for other modules as well (ngResource, ngCookies): - wrap into a function - add license - add version Breaks `$sanitize` service, `ngBindHtml` directive and `linky` filter were moved to the `ngSanitize` module. Apps that depend on any of these will need to load `angular-sanitize.js` and include `ngSanitize` in their dependency list: `var myApp = angular.module('myApp', ['ngSanitize']);`
Diffstat (limited to 'test')
-rw-r--r--test/ng/directive/ngBindSpec.js28
-rw-r--r--test/ng/filter/filtersSpec.js26
-rw-r--r--test/ngSanitize/directive/ngBindHtmlSpec.js25
-rw-r--r--test/ngSanitize/filter/linkySpec.js27
-rw-r--r--test/ngSanitize/sanitizeSpec.js (renamed from test/ng/sanitizeSpec.js)13
-rw-r--r--test/ngScenario/dslSpec.js2
6 files changed, 64 insertions, 57 deletions
diff --git a/test/ng/directive/ngBindSpec.js b/test/ng/directive/ngBindSpec.js
index b3c63b34..da291fa4 100644
--- a/test/ng/directive/ngBindSpec.js
+++ b/test/ng/directive/ngBindSpec.js
@@ -67,39 +67,13 @@ describe('ngBind*', function() {
});
- describe('ngBindHtml', function() {
-
- it('should set html', inject(function($rootScope, $compile) {
- element = $compile('<div ng-bind-html="html"></div>')($rootScope);
- $rootScope.html = '<div unknown>hello</div>';
- $rootScope.$digest();
- expect(lowercase(element.html())).toEqual('<div>hello</div>');
- }));
-
-
- it('should reset html when value is null or undefined', inject(function($compile, $rootScope) {
- element = $compile('<div ng-bind-html="html"></div>')($rootScope);
-
- forEach([null, undefined, ''], function(val) {
- $rootScope.html = 'some val';
- $rootScope.$digest();
- expect(lowercase(element.html())).toEqual('some val');
-
- $rootScope.html = val;
- $rootScope.$digest();
- expect(lowercase(element.html())).toEqual('');
- });
- }));
- });
-
-
describe('ngBindHtmlUnsafe', function() {
it('should set unsafe html', inject(function($rootScope, $compile) {
element = $compile('<div ng-bind-html-unsafe="html"></div>')($rootScope);
$rootScope.html = '<div onclick="">hello</div>';
$rootScope.$digest();
- expect(lowercase(element.html())).toEqual('<div onclick="">hello</div>');
+ expect(angular.lowercase(element.html())).toEqual('<div onclick="">hello</div>');
}));
});
});
diff --git a/test/ng/filter/filtersSpec.js b/test/ng/filter/filtersSpec.js
index 9ea200a3..55476882 100644
--- a/test/ng/filter/filtersSpec.js
+++ b/test/ng/filter/filtersSpec.js
@@ -153,32 +153,6 @@ describe('filters', function() {
});
});
- describe('linky', function() {
- var linky;
-
- beforeEach(inject(function($filter){
- linky = $filter('linky')
- }));
-
- it('should do basic filter', function() {
- expect(linky("http://ab/ (http://a/) <http://a/> http://1.2/v:~-123. c")).
- toEqual('<a href="http://ab/">http://ab/</a> ' +
- '(<a href="http://a/">http://a/</a>) ' +
- '&lt;<a href="http://a/">http://a/</a>&gt; ' +
- '<a href="http://1.2/v:~-123">http://1.2/v:~-123</a>. c');
- expect(linky(undefined)).not.toBeDefined();
- });
-
- it('should handle mailto:', function() {
- expect(linky("mailto:me@example.com")).
- toEqual('<a href="mailto:me@example.com">me@example.com</a>');
- expect(linky("me@example.com")).
- toEqual('<a href="mailto:me@example.com">me@example.com</a>');
- expect(linky("send email to me@example.com, but")).
- toEqual('send email to <a href="mailto:me@example.com">me@example.com</a>, but');
- });
- });
-
describe('date', function() {
var morning = new angular.mock.TzDate(+5, '2010-09-03T12:05:08.000Z'); //7am
diff --git a/test/ngSanitize/directive/ngBindHtmlSpec.js b/test/ngSanitize/directive/ngBindHtmlSpec.js
new file mode 100644
index 00000000..be23e5a5
--- /dev/null
+++ b/test/ngSanitize/directive/ngBindHtmlSpec.js
@@ -0,0 +1,25 @@
+describe('ngBindHtml', function() {
+ beforeEach(module('ngSanitize'));
+
+ it('should set html', inject(function($rootScope, $compile) {
+ element = $compile('<div ng-bind-html="html"></div>')($rootScope);
+ $rootScope.html = '<div unknown>hello</div>';
+ $rootScope.$digest();
+ expect(angular.lowercase(element.html())).toEqual('<div>hello</div>');
+ }));
+
+
+ it('should reset html when value is null or undefined', inject(function($compile, $rootScope) {
+ element = $compile('<div ng-bind-html="html"></div>')($rootScope);
+
+ angular.forEach([null, undefined, ''], function(val) {
+ $rootScope.html = 'some val';
+ $rootScope.$digest();
+ expect(angular.lowercase(element.html())).toEqual('some val');
+
+ $rootScope.html = val;
+ $rootScope.$digest();
+ expect(angular.lowercase(element.html())).toEqual('');
+ });
+ }));
+});
diff --git a/test/ngSanitize/filter/linkySpec.js b/test/ngSanitize/filter/linkySpec.js
new file mode 100644
index 00000000..0448159a
--- /dev/null
+++ b/test/ngSanitize/filter/linkySpec.js
@@ -0,0 +1,27 @@
+describe('linky', function() {
+ var linky;
+
+ beforeEach(module('ngSanitize'));
+
+ beforeEach(inject(function($filter){
+ linky = $filter('linky');
+ }));
+
+ it('should do basic filter', function() {
+ expect(linky("http://ab/ (http://a/) <http://a/> http://1.2/v:~-123. c")).
+ toEqual('<a href="http://ab/">http://ab/</a> ' +
+ '(<a href="http://a/">http://a/</a>) ' +
+ '&lt;<a href="http://a/">http://a/</a>&gt; ' +
+ '<a href="http://1.2/v:~-123">http://1.2/v:~-123</a>. c');
+ expect(linky(undefined)).not.toBeDefined();
+ });
+
+ it('should handle mailto:', function() {
+ expect(linky("mailto:me@example.com")).
+ toEqual('<a href="mailto:me@example.com">me@example.com</a>');
+ expect(linky("me@example.com")).
+ toEqual('<a href="mailto:me@example.com">me@example.com</a>');
+ expect(linky("send email to me@example.com, but")).
+ toEqual('send email to <a href="mailto:me@example.com">me@example.com</a>, but');
+ });
+});
diff --git a/test/ng/sanitizeSpec.js b/test/ngSanitize/sanitizeSpec.js
index a33d8992..b4fd8a2a 100644
--- a/test/ng/sanitizeSpec.js
+++ b/test/ngSanitize/sanitizeSpec.js
@@ -4,6 +4,8 @@ describe('HTML', function() {
var expectHTML;
+ beforeEach(module('ngSanitize'));
+
beforeEach(inject(function($sanitize) {
expectHTML = function(html){
return expect($sanitize(html));
@@ -11,6 +13,8 @@ describe('HTML', function() {
}));
describe('htmlParser', function() {
+ if (angular.isUndefined(window.htmlParser)) return;
+
var handler, start, text;
beforeEach(function() {
handler = {
@@ -22,8 +26,8 @@ describe('HTML', function() {
};
// Since different browsers handle newlines differenttly we trim
// so that it is easier to write tests.
- forEach(attrs, function(value, key){
- attrs[key] = trim(value);
+ angular.forEach(attrs, function(value, key) {
+ attrs[key] = value.replace(/^\s*/, '').replace(/\s*$/, '')
});
},
chars: function(text_){
@@ -64,9 +68,9 @@ describe('HTML', function() {
expect(start).toEqual({tag:'option', attrs:{selected:'', value:''}, unary:false});
expect(text).toEqual('abc');
});
-
});
+ // THESE TESTS ARE EXECUTED WITH COMPILED ANGULAR
it('should echo html', function() {
expectHTML('hello<b class="1\'23" align=\'""\'>world</b>.').
toEqual('hello<b class="1\'23" align="&#34;&#34;">world</b>.');
@@ -141,6 +145,8 @@ describe('HTML', function() {
});
describe('htmlSanitizerWriter', function() {
+ if (angular.isUndefined(window.htmlSanitizeWriter)) return;
+
var writer, html;
beforeEach(function() {
html = '';
@@ -277,5 +283,4 @@ describe('HTML', function() {
});
});
-
});
diff --git a/test/ngScenario/dslSpec.js b/test/ngScenario/dslSpec.js
index 0a8ab762..fee5c3b5 100644
--- a/test/ngScenario/dslSpec.js
+++ b/test/ngScenario/dslSpec.js
@@ -9,6 +9,8 @@ describe("angular.scenario.dsl", function() {
dealoc(element);
});
+ beforeEach(module('ngSanitize'));
+
beforeEach(inject(function($injector) {
eventLog = [];
$window = {