fixed the keystroke_urls_become_clickable.js test

This commit is contained in:
Peter 'Pita' Martischka 2012-10-06 21:45:46 +02:00
parent 7fd23c8d71
commit 35cea1e542
2 changed files with 20 additions and 15 deletions

View File

@ -98,7 +98,11 @@ var helper = {};
}} }}
var intervalCheck = setInterval(function(){ var intervalCheck = setInterval(function(){
var passed = conditionFunc(); var passed = false;
try {
passed = conditionFunc();
} catch(e){}
if(passed){ if(passed){
clearInterval(intervalCheck); clearInterval(intervalCheck);

View File

@ -1,32 +1,33 @@
describe("urls become clickable", function(){ describe("urls become clickable", function(){
//create a new pad before each test run //create a new pad before each test run
beforeEach(function(cb){ beforeEach(function(cb){
testHelper.newPad(cb); helper.newPad(cb);
}); });
it("adds a url and makes sure it's clickable", function() { it("adds a url and makes sure it's clickable", function(done) {
//get the inner iframe var inner$ = helper.jQueryOf("inner");
var $inner = testHelper.$getPadInner(); var chrome$ = helper.jQueryOf("chrome");
//get the first text element out of the inner iframe //get the first text element out of the inner iframe
var firstTextElement = $inner.find("div").first(); var firstTextElement = inner$("div").first();
// simulate key presses to delete content // simulate key presses to delete content
firstTextElement.sendkeys('{selectall}'); // select all firstTextElement.sendkeys('{selectall}'); // select all
firstTextElement.sendkeys('{del}'); // clear the first line firstTextElement.sendkeys('{del}'); // clear the first line
firstTextElement.sendkeys('http://etherpad.org'); // insert a URL firstTextElement.sendkeys('http://etherpad.org'); // insert a URL
// setTimeout(function(){ helper.waitFor(function(){
//ace creates a new dom element when you press a keystroke, so just get the first text element again //ace creates a new dom element when you press a keystroke, so just get the first text element again
var newFirstTextElement = $inner.find("div").first(); var newFirstTextElement = inner$("div").first();
var locatedHref = newFirstTextElement.find("a").contents().text(); var locatedHref = newFirstTextElement.find("a");
var isURL = locatedHref.indexOf("http://etherpad.org") != -1; // if we found a URL and it is for etherpad.org var isURL = locatedHref.length == 1; // if we found a URL and it is for etherpad.org
console.log(isURL); //expect it to be bold
expect(isURL).to.be(true);
//expect it to be bold
expect(isURL).to.be(true);
// }, 1000);
//it will only come to this point if the expect statement above doesn't throw
done();
return true;
});
}); });
}); });