From dc7b764d4da500682799234b32b6bd44e73c5d41 Mon Sep 17 00:00:00 2001
From: Igor Minar
Date: Sun, 8 Apr 2012 02:40:28 -0700
Subject: test(ngBindSpec): correct tests + split them up
---
test/ng/directive/ngBindSpec.js | 45 ++++++++++++++++++++++++++++-------------
1 file changed, 31 insertions(+), 14 deletions(-)
(limited to 'test/ng/directive')
diff --git a/test/ng/directive/ngBindSpec.js b/test/ng/directive/ngBindSpec.js
index 01a07c52..c83c8c85 100644
--- a/test/ng/directive/ngBindSpec.js
+++ b/test/ng/directive/ngBindSpec.js
@@ -20,6 +20,7 @@ describe('ng-bind-*', function() {
expect(element.text()).toEqual('misko');
}));
+
it('should set text to blank if undefined', inject(function($rootScope, $compile) {
element = $compile('
')($rootScope);
$rootScope.a = 'misko';
@@ -33,26 +34,19 @@ describe('ng-bind-*', function() {
expect(element.text()).toEqual('');
}));
- it('should set html', inject(function($rootScope, $compile) {
- element = $compile('')($rootScope);
- $rootScope.html = 'hello
';
- $rootScope.$digest();
- expect(lowercase(element.html())).toEqual('hello
');
- }));
-
- it('should set unsafe html', inject(function($rootScope, $compile) {
- element = $compile('')($rootScope);
- $rootScope.html = 'hello
';
- $rootScope.$digest();
- expect(lowercase(element.html())).toEqual('hello
');
- }));
it('should suppress rendering of falsy values', inject(function($rootScope, $compile) {
- element = $compile('{{ null }}{{ undefined }}{{ "" }}-{{ 0 }}{{ false }}
')($rootScope);
+ element = $compile('' +
+ '' +
+ '-' +
+ '' +
+ '' +
+ '
')($rootScope);
$rootScope.$digest();
expect(element.text()).toEqual('-0false');
}));
+
it('should render object as JSON ignore $$', inject(function($rootScope, $compile) {
element = $compile('{{ {key:"value", $$key:"hide"} }}
')($rootScope);
$rootScope.$digest();
@@ -71,10 +65,33 @@ describe('ng-bind-*', function() {
expect(element.text()).toEqual('Hello Misko!');
}));
+
it('should render object as JSON ignore $$', inject(function($rootScope, $compile) {
element = $compile('{{ {key:"value", $$key:"hide"} }}')($rootScope);
$rootScope.$digest();
expect(fromJson(element.text())).toEqual({key:'value'});
}));
});
+
+
+ describe('ng-bind-html', function() {
+
+ it('should set html', inject(function($rootScope, $compile) {
+ element = $compile('')($rootScope);
+ $rootScope.html = 'hello
';
+ $rootScope.$digest();
+ expect(lowercase(element.html())).toEqual('hello
');
+ }));
+ });
+
+
+ describe('ng-bind-html-unsafe', function() {
+
+ it('should set unsafe html', inject(function($rootScope, $compile) {
+ element = $compile('')($rootScope);
+ $rootScope.html = 'hello
';
+ $rootScope.$digest();
+ expect(lowercase(element.html())).toEqual('hello
');
+ }));
+ });
});
--
cgit v1.2.3