Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 1c670b2

Browse files
committed
added ng:include
1 parent 7a4b480 commit 1c670b2

File tree

6 files changed

+55
-12
lines changed

6 files changed

+55
-12
lines changed

lib/jstestdriver/JsTestDriver.jar

32.2 KB
Binary file not shown.

src/delete/Widgets.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ PopUp.onOver = function(e) {
729729
jNode.bind(PopUp.OUT_EVENT, PopUp.onOut);
730730
var position = jNode.position();
731731
var de = document.documentElement;
732-
var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
732+
var w = self.innerWidth || (de && de.clientWidth) || document.body.clientWidth;
733733
var hasArea = w - position.left;
734734
var width = 300;
735735
var title = jNode.hasClass("ng-exception") ? "EXCEPTION:" : "Validation error...";

test/angular-mocks.js

+29-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,36 @@
11

22
function MockBrowser() {
3-
this.url = "http://server";
4-
this.watches = [];
3+
var self = this, expectations = {}, requests = [];
4+
self.url = "http://server";
5+
self.watches = [];
6+
7+
self.xhr = function(method, url, callback) {
8+
var expect = expectations[method] || {};
9+
var response = expect[url];
10+
if (!response) {
11+
throw "Unexepected request for mothod '" + method + "' and url '" + url + "'.";
12+
}
13+
requests.push(function(){
14+
callback(200, response);
15+
});
16+
};
17+
self.xhr.expectations = expectations;
18+
self.xhr.requests = requests;
19+
self.xhr.expect = function(method, url) {
20+
var expect = expectations[method] || (expectations[method] = {});
21+
return {
22+
respond: function(response) {
23+
expect[url] = response;
24+
}
25+
};
26+
};
27+
self.xhr.flush = function() {
28+
while(requests.length) {
29+
requests.pop()();
30+
}
31+
};
532
}
633
MockBrowser.prototype = {
7-
xhr: function(method, url, callback) {
8-
9-
},
1034

1135
getUrl: function(){
1236
return this.url;

test/directivesSpec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe("directives", function(){
1313
});
1414

1515
afterEach(function() {
16-
model.$element.remove();
16+
if (model && model.$element) model.$element.remove();
1717
expect(size(jqCache)).toEqual(0);
1818
});
1919

test/testabilityPatch.js

+18-4
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,28 @@ function nakedExpect(obj) {
55
return expect(angular.fromJson(angular.toJson(obj)));
66
}
77

8-
angularService('$browser', function(){
9-
return new MockBrowser();
10-
});
11-
128
function childNode(element, index) {
139
return jqLite(element[0].childNodes[index]);
1410
}
1511

12+
extend(angular, {
13+
'element': jqLite,
14+
'compile': compile,
15+
'scope': createScope,
16+
'copy': copy,
17+
'extend': extend,
18+
'foreach': foreach,
19+
'noop':noop,
20+
'identity':identity,
21+
'isUndefined': isUndefined,
22+
'isDefined': isDefined,
23+
'isString': isString,
24+
'isFunction': isFunction,
25+
'isNumber': isNumber,
26+
'isArray': isArray
27+
});
28+
29+
1630
function sortedHtml(element) {
1731
var html = "";
1832
(function toString(node) {

test/widgetsSpec.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,11 @@ describe("input widget", function(){
203203
describe('ng:include', function(){
204204
it('should include on external file', function() {
205205
var element = jqLite('<ng:include src="myUrl"></ng:include>');
206-
var scope = compile(element).$init();
206+
var scope = compile(element);
207+
scope.$browser.xhr.expect('GET', 'myUrl').respond('hello');
208+
scope.$init();
209+
expect(sortedHtml(element)).toEqual('<ng:include src="myUrl" switch-instance="compiled"></ng:include>');
210+
scope.$browser.xhr.flush();
211+
expect(sortedHtml(element)).toEqual('<ng:include src="myUrl" switch-instance="compiled">hello</ng:include>');
207212
});
208213
});

0 commit comments

Comments
 (0)