mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-22 00:16:15 -04:00
added a runIn method to the helper
This commit is contained in:
parent
ca6ebd6151
commit
d4c851875a
2 changed files with 37 additions and 3 deletions
|
@ -118,6 +118,13 @@ var helper = {};
|
||||||
return deferred;
|
return deferred;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
helper.runIn = function($iframe, func){
|
||||||
|
var eval = $iframe.window.eval;
|
||||||
|
var funcStr = "(" + func.toString() + ")()";
|
||||||
|
|
||||||
|
return eval(funcStr);
|
||||||
|
}
|
||||||
|
|
||||||
/* Ensure console.log doesn't blow up in IE, ugly but ok for a test framework imho*/
|
/* Ensure console.log doesn't blow up in IE, ugly but ok for a test framework imho*/
|
||||||
window.console = window.console || {};
|
window.console = window.console || {};
|
||||||
window.console.log = window.console.log || function(){}
|
window.console.log = window.console.log || function(){}
|
||||||
|
@ -126,9 +133,11 @@ var helper = {};
|
||||||
var _it = it;
|
var _it = it;
|
||||||
it = function(name, func){
|
it = function(name, func){
|
||||||
if(func && func.length !== 1){
|
if(func && func.length !== 1){
|
||||||
throw new Error("Please use always a callback with it() - " + func.toString());
|
func = function(){
|
||||||
|
throw new Error("Please use always a callback with it() - " + func.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_it.apply(null, arguments);
|
_it(name, func);
|
||||||
}
|
}
|
||||||
})()
|
})()
|
|
@ -1,7 +1,32 @@
|
||||||
describe("the test helper", function(){
|
describe("the test helper", function(){
|
||||||
|
describe("the runIn method", function(){
|
||||||
|
it("runs the function in the correct iframe", function(done){
|
||||||
|
this.timeout(5000);
|
||||||
|
|
||||||
|
helper.newPad(function(){
|
||||||
|
var chromeLength = helper.runIn(helper.padChrome$, function(){
|
||||||
|
return $("#editbar").length;
|
||||||
|
});
|
||||||
|
|
||||||
|
var outerLength = helper.runIn(helper.padOuter$, function(){
|
||||||
|
return $("#outerdocbody").length;
|
||||||
|
});
|
||||||
|
|
||||||
|
var innerLength = helper.runIn(helper.padInner$, function(){
|
||||||
|
return $("#innerdocbody").length;
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(chromeLength).to.be(1);
|
||||||
|
expect(outerLength).to.be(1);
|
||||||
|
expect(innerLength).to.be(1);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("the newPad method", function(){
|
describe("the newPad method", function(){
|
||||||
xit("doesn't leak memory if you creates iframes over and over again", function(done){
|
xit("doesn't leak memory if you creates iframes over and over again", function(done){
|
||||||
this.timeout(200000);
|
this.timeout(100000);
|
||||||
|
|
||||||
var times = 10;
|
var times = 10;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue