diff options
| author | Igor Minar | 2012-03-08 15:00:38 -0800 |
|---|---|---|
| committer | Igor Minar | 2012-03-08 22:29:34 -0800 |
| commit | f54db2ccda399f2677e4ca7588018cb31545a2b4 (patch) | |
| tree | 29ef2f8f834544c84cea1a82e3d08679358fb992 /test/directive/scriptSpec.js | |
| parent | dd7b0f56fcd9785f7fccae8c4f088a8f3e7b125e (diff) | |
| download | angular.js-f54db2ccda399f2677e4ca7588018cb31545a2b4.tar.bz2 | |
chore(directives,widgets): reorg the code under directive/ dir
Diffstat (limited to 'test/directive/scriptSpec.js')
| -rw-r--r-- | test/directive/scriptSpec.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/directive/scriptSpec.js b/test/directive/scriptSpec.js new file mode 100644 index 00000000..471e04ce --- /dev/null +++ b/test/directive/scriptSpec.js @@ -0,0 +1,44 @@ +'use strict'; + +describe('scriptDirective', function() { + var element; + + + afterEach(function(){ + dealoc(element); + }); + + + it('should populate $templateCache with contents of a ng-template script element', inject( + function($compile, $templateCache) { + if (msie <=8) return; + // in ie8 it is not possible to create a script tag with the right content. + // it always comes up as empty. I was trying to set the text of the + // script tag, but that did not work either, so I gave up. + $compile('<div>foo' + + '<script id="/ignore">ignore me</script>' + + '<script type="text/ng-template" id="/myTemplate.html"><x>{{y}}</x></script>' + + '</div>' ); + expect($templateCache.get('/myTemplate.html')).toBe('<x>{{y}}</x>'); + expect($templateCache.get('/ignore')).toBeUndefined(); + } + )); + + + it('should not compile scripts', inject(function($compile, $templateCache, $rootScope) { + if (msie <=8) return; // see above + + var doc = jqLite('<div></div>'); + // jQuery is too smart and removes + doc[0].innerHTML = '<script type="text/javascript">some {{binding}}</script>' + + '<script type="text/ng-template" id="/some">other {{binding}}</script>'; + + $compile(doc)($rootScope); + $rootScope.$digest(); + + var scripts = doc.find('script'); + expect(scripts.eq(0).text()).toBe('some {{binding}}'); + expect(scripts.eq(1).text()).toBe('other {{binding}}'); + dealoc(doc); + })); +}); |
