From f54db2ccda399f2677e4ca7588018cb31545a2b4 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Thu, 8 Mar 2012 15:00:38 -0800 Subject: chore(directives,widgets): reorg the code under directive/ dir --- test/directive/ngBindSpec.js | 113 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 test/directive/ngBindSpec.js (limited to 'test/directive/ngBindSpec.js') diff --git a/test/directive/ngBindSpec.js b/test/directive/ngBindSpec.js new file mode 100644 index 00000000..e8c07494 --- /dev/null +++ b/test/directive/ngBindSpec.js @@ -0,0 +1,113 @@ +'use strict'; + +describe('ng:bind-*', function() { + var element; + + + afterEach(function() { + dealoc(element); + }); + + + describe('ng:bind', function() { + + it('should set text', inject(function($rootScope, $compile) { + element = $compile('
')($rootScope); + expect(element.text()).toEqual(''); + $rootScope.a = 'misko'; + $rootScope.$digest(); + expect(element.hasClass('ng-binding')).toEqual(true); + expect(element.text()).toEqual('misko'); + })); + + it('should set text to blank if undefined', inject(function($rootScope, $compile) { + element = $compile('')($rootScope); + $rootScope.a = 'misko'; + $rootScope.$digest(); + expect(element.text()).toEqual('misko'); + $rootScope.a = undefined; + $rootScope.$digest(); + expect(element.text()).toEqual(''); + $rootScope.a = null; + $rootScope.$digest(); + expect(element.text()).toEqual(''); + })); + + it('should set html', inject(function($rootScope, $compile) { + element = $compile('')($rootScope); + $rootScope.html = '{{ {key:"value", $$key:"hide"} }}')($rootScope);
+ $rootScope.$digest();
+ expect(fromJson(element.text())).toEqual({key:'value'});
+ }));
+ });
+
+
+ describe('ng:bind-attr', function() {
+ it('should bind attributes', inject(function($rootScope, $compile) {
+ element = $compile('')($rootScope);
+ $rootScope.$digest();
+ expect(element.attr('src')).toEqual('http://localhost/mysrc');
+ expect(element.attr('alt')).toEqual('myalt');
+ }));
+
+ it('should not pretty print JSON in attributes', inject(function($rootScope, $compile) {
+ element = $compile('