From 23b255a8b7481ff5c06004b3558c07f981c42276 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Mon, 7 Feb 2011 15:29:56 -0800 Subject: remove $init on scope from applying compilation template Closes #40 --- test/BinderSpec.js | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'test/BinderSpec.js') diff --git a/test/BinderSpec.js b/test/BinderSpec.js index 73650bd6..c3f90ad7 100644 --- a/test/BinderSpec.js +++ b/test/BinderSpec.js @@ -3,16 +3,18 @@ describe('Binder', function(){ beforeEach(function(){ var self = this; - this.compile = function(html, initialScope, parent) { + this.compile = function(html, parent) { var compiler = new Compiler(angularTextMarkup, angularAttrMarkup, angularDirective, angularWidget); if (self.element) dealoc(self.element); - var element = self.element = jqLite(html); + var element; + if (parent) { + parent.html(html); + element = parent.children(); + } else { + element = jqLite(html); + } + self.element = element; var scope = compiler.compile(element)(element); - - if (parent) parent.append(element); - - extend(scope, initialScope); - scope.$init(); return {node:element, scope:scope}; }; this.compileToHtml = function (content) { @@ -27,8 +29,8 @@ describe('Binder', function(){ }); - it('ChangingTextfieldUpdatesModel', function(){ - var state = this.compile('', {model:{}}); + it('text-field should default to value attribute', function(){ + var state = this.compile(''); state.scope.$eval(); assertEquals('abc', state.scope.model.price); }); @@ -443,8 +445,7 @@ describe('Binder', function(){ }); it('ActionOnAHrefThrowsError', function(){ - var model = {books:[]}; - var c = this.compile('Add Phone', model); + var c = this.compile('Add Phone'); c.scope.action = function(){ throw new Error('MyError'); }; @@ -517,9 +518,9 @@ describe('Binder', function(){ }); it('ValidateForm', function(){ - var c = this.compile('
' + - '
', - undefined, jqLite(document.body)); + var c = this.compile('
' + + '
', + jqLite(document.body)); var items = [{}, {}]; c.scope.$set("items", items); c.scope.$eval(); @@ -547,7 +548,7 @@ describe('Binder', function(){ }); it('ValidateOnlyVisibleItems', function(){ - var c = this.compile('
', undefined, jqLite(document.body)); + var c = this.compile('
', jqLite(document.body)); c.scope.$set("show", true); c.scope.$eval(); assertEquals(2, c.scope.$service('$invalidWidgets').length); -- cgit v1.2.3