diff options
| author | Misko Hevery | 2010-03-23 14:57:11 -0700 |
|---|---|---|
| committer | Misko Hevery | 2010-03-23 14:57:11 -0700 |
| commit | bb98ae14f2aef74efbd8345e93f62ac67f460f7f (patch) | |
| tree | b50ac4417c7b1bda996dd569069d7eb834eef2ff /test/markupSpec.js | |
| parent | 6ff550cfa9524bbb124d10caf1fc13c911ab3b4b (diff) | |
| download | angular.js-bb98ae14f2aef74efbd8345e93f62ac67f460f7f.tar.bz2 | |
markup now wroks, some refactorings
Diffstat (limited to 'test/markupSpec.js')
| -rw-r--r-- | test/markupSpec.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/test/markupSpec.js b/test/markupSpec.js new file mode 100644 index 00000000..9e89af7b --- /dev/null +++ b/test/markupSpec.js @@ -0,0 +1,49 @@ +describe("markups", function(){ + + var compile, element, scope; + + beforeEach(function() { + scope = null; + element = null; + var compiler = new Compiler(angularTextMarkup, angularAttrMarkup, angularDirective, angularWidget); + compile = function(html) { + element = jqLite(html); + var view = compiler.compile(element)(element); + view.init(); + scope = view.scope; + }; + }); + + afterEach(function(){ + if (element) { + element.remove(); + } + expect(_(jqCache).size()).toEqual(0); + }); + + it('should translate {{}} in text', function(){ + compile('<div>hello {{name}}!</div>'); + expect(element.html()).toEqual('hello <span ng-bind="name"></span>!'); + scope.set('name', 'Misko'); + scope.updateView(); + expect(element.html()).toEqual('hello <span ng-bind="name">Misko</span>!'); + }); + + it('should translate {{}} in terminal nodes', function(){ + compile('<select><option>Greet {{name}}!</option></select>'); + expect(element.html()).toEqual('<option ng-bind-template="Greet {{name}}!"></option>'); + scope.set('name', 'Misko'); + scope.updateView(); + expect(element.html()).toEqual('<option ng-bind-template="Greet {{name}}!">Greet Misko!</option>'); + }); + + it('should translate {{}} in attributes', function(){ + compile('<img src="http://server/{{path}}.png"/>'); + expect(element.attr('src')).toEqual(); + expect(element.attr('ng-bind-attr')).toEqual('{"src":"http://server/{{path}}.png"}'); + scope.set('path', 'a/b'); + scope.updateView(); + expect(element.attr('src')).toEqual("http://server/a/b.png"); + }); + +}); |
