mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-19 20:01:52 +00:00
added ng:include
This commit is contained in:
parent
7a4b480206
commit
1c670b2a7c
6 changed files with 55 additions and 12 deletions
Binary file not shown.
|
|
@ -729,7 +729,7 @@ PopUp.onOver = function(e) {
|
||||||
jNode.bind(PopUp.OUT_EVENT, PopUp.onOut);
|
jNode.bind(PopUp.OUT_EVENT, PopUp.onOut);
|
||||||
var position = jNode.position();
|
var position = jNode.position();
|
||||||
var de = document.documentElement;
|
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 hasArea = w - position.left;
|
||||||
var width = 300;
|
var width = 300;
|
||||||
var title = jNode.hasClass("ng-exception") ? "EXCEPTION:" : "Validation error...";
|
var title = jNode.hasClass("ng-exception") ? "EXCEPTION:" : "Validation error...";
|
||||||
|
|
|
||||||
34
test/angular-mocks.js
vendored
34
test/angular-mocks.js
vendored
|
|
@ -1,12 +1,36 @@
|
||||||
|
|
||||||
function MockBrowser() {
|
function MockBrowser() {
|
||||||
this.url = "http://server";
|
var self = this, expectations = {}, requests = [];
|
||||||
this.watches = [];
|
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 = {
|
MockBrowser.prototype = {
|
||||||
xhr: function(method, url, callback) {
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
getUrl: function(){
|
getUrl: function(){
|
||||||
return this.url;
|
return this.url;
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ describe("directives", function(){
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
model.$element.remove();
|
if (model && model.$element) model.$element.remove();
|
||||||
expect(size(jqCache)).toEqual(0);
|
expect(size(jqCache)).toEqual(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,14 +5,28 @@ function nakedExpect(obj) {
|
||||||
return expect(angular.fromJson(angular.toJson(obj)));
|
return expect(angular.fromJson(angular.toJson(obj)));
|
||||||
}
|
}
|
||||||
|
|
||||||
angularService('$browser', function(){
|
|
||||||
return new MockBrowser();
|
|
||||||
});
|
|
||||||
|
|
||||||
function childNode(element, index) {
|
function childNode(element, index) {
|
||||||
return jqLite(element[0].childNodes[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) {
|
function sortedHtml(element) {
|
||||||
var html = "";
|
var html = "";
|
||||||
(function toString(node) {
|
(function toString(node) {
|
||||||
|
|
|
||||||
|
|
@ -203,6 +203,11 @@ describe("input widget", function(){
|
||||||
describe('ng:include', function(){
|
describe('ng:include', function(){
|
||||||
it('should include on external file', function() {
|
it('should include on external file', function() {
|
||||||
var element = jqLite('<ng:include src="myUrl"></ng:include>');
|
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>');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue