diff options
| author | Misko Hevery | 2010-04-05 14:09:25 -0700 |
|---|---|---|
| committer | Misko Hevery | 2010-04-05 14:09:25 -0700 |
| commit | 1c670b2a7c3f6153ea2e5047722f7151b9795b33 (patch) | |
| tree | 08d9baac79e65425db3f24fd8bb06a489d855b1f | |
| parent | 7a4b48020688060debe9cb0f9c17615d7585cbe7 (diff) | |
| download | angular.js-1c670b2a7c3f6153ea2e5047722f7151b9795b33.tar.bz2 | |
added ng:include
| -rw-r--r-- | lib/jstestdriver/JsTestDriver.jar | bin | 3094180 -> 3127185 bytes | |||
| -rw-r--r-- | src/delete/Widgets.js | 2 | ||||
| -rw-r--r-- | test/angular-mocks.js | 34 | ||||
| -rw-r--r-- | test/directivesSpec.js | 2 | ||||
| -rw-r--r-- | test/testabilityPatch.js | 22 | ||||
| -rw-r--r-- | test/widgetsSpec.js | 7 |
6 files changed, 55 insertions, 12 deletions
diff --git a/lib/jstestdriver/JsTestDriver.jar b/lib/jstestdriver/JsTestDriver.jar Binary files differindex abd3c5f3..557d4c16 100644 --- a/lib/jstestdriver/JsTestDriver.jar +++ b/lib/jstestdriver/JsTestDriver.jar diff --git a/src/delete/Widgets.js b/src/delete/Widgets.js index 74f70f21..96b63793 100644 --- a/src/delete/Widgets.js +++ b/src/delete/Widgets.js @@ -729,7 +729,7 @@ PopUp.onOver = function(e) { jNode.bind(PopUp.OUT_EVENT, PopUp.onOut); var position = jNode.position(); var de = document.documentElement; - var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth; + var w = self.innerWidth || (de && de.clientWidth) || document.body.clientWidth; var hasArea = w - position.left; var width = 300; var title = jNode.hasClass("ng-exception") ? "EXCEPTION:" : "Validation error..."; diff --git a/test/angular-mocks.js b/test/angular-mocks.js index ab3638b1..9c93f87f 100644 --- a/test/angular-mocks.js +++ b/test/angular-mocks.js @@ -1,12 +1,36 @@ function MockBrowser() { - this.url = "http://server"; - this.watches = []; + var self = this, expectations = {}, requests = []; + self.url = "http://server"; + self.watches = []; + + self.xhr = function(method, url, callback) { + var expect = expectations[method] || {}; + var response = expect[url]; + if (!response) { + throw "Unexepected request for mothod '" + method + "' and url '" + url + "'."; + } + requests.push(function(){ + callback(200, response); + }); + }; + self.xhr.expectations = expectations; + self.xhr.requests = requests; + self.xhr.expect = function(method, url) { + var expect = expectations[method] || (expectations[method] = {}); + return { + respond: function(response) { + expect[url] = response; + } + }; + }; + self.xhr.flush = function() { + while(requests.length) { + requests.pop()(); + } + }; } MockBrowser.prototype = { - xhr: function(method, url, callback) { - - }, getUrl: function(){ return this.url; diff --git a/test/directivesSpec.js b/test/directivesSpec.js index cfee86a0..06a3a2dd 100644 --- a/test/directivesSpec.js +++ b/test/directivesSpec.js @@ -13,7 +13,7 @@ describe("directives", function(){ }); afterEach(function() { - model.$element.remove(); + if (model && model.$element) model.$element.remove(); expect(size(jqCache)).toEqual(0); }); diff --git a/test/testabilityPatch.js b/test/testabilityPatch.js index b2ee5526..dc67ddec 100644 --- a/test/testabilityPatch.js +++ b/test/testabilityPatch.js @@ -5,14 +5,28 @@ function nakedExpect(obj) { return expect(angular.fromJson(angular.toJson(obj))); } -angularService('$browser', function(){ - return new MockBrowser(); -}); - function childNode(element, index) { return jqLite(element[0].childNodes[index]); } +extend(angular, { + 'element': jqLite, + 'compile': compile, + 'scope': createScope, + 'copy': copy, + 'extend': extend, + 'foreach': foreach, + 'noop':noop, + 'identity':identity, + 'isUndefined': isUndefined, + 'isDefined': isDefined, + 'isString': isString, + 'isFunction': isFunction, + 'isNumber': isNumber, + 'isArray': isArray +}); + + function sortedHtml(element) { var html = ""; (function toString(node) { diff --git a/test/widgetsSpec.js b/test/widgetsSpec.js index 63c18700..1669aa68 100644 --- a/test/widgetsSpec.js +++ b/test/widgetsSpec.js @@ -203,6 +203,11 @@ describe("input widget", function(){ describe('ng:include', function(){ it('should include on external file', function() { var element = jqLite('<ng:include src="myUrl"></ng:include>'); - var scope = compile(element).$init(); + var scope = compile(element); + scope.$browser.xhr.expect('GET', 'myUrl').respond('hello'); + scope.$init(); + expect(sortedHtml(element)).toEqual('<ng:include src="myUrl" switch-instance="compiled"></ng:include>'); + scope.$browser.xhr.flush(); + expect(sortedHtml(element)).toEqual('<ng:include src="myUrl" switch-instance="compiled">hello</ng:include>'); }); }); |
