Fixed test-names, use waitFor instead of setTimeout

This commit is contained in:
mluto 2013-01-13 11:03:52 +01:00
parent 176719b331
commit c3dd433c99
1 changed files with 26 additions and 25 deletions

View File

@ -1,9 +1,9 @@
describe("chat-load-messages", function(){ describe("chat-load-messages", function(){
it("create pad", function(done) { it("creates a pad", function(done) {
helper.newPad(done); helper.newPad(done);
}); });
it("add a lot of messages", function(done) { it("adds a lot of messages", function(done) {
var inner$ = helper.padInner$; var inner$ = helper.padInner$;
var chrome$ = helper.padChrome$; var chrome$ = helper.padChrome$;
var chatButton = chrome$("#chaticon"); var chatButton = chrome$("#chaticon");
@ -21,26 +21,29 @@ describe("chat-load-messages", function(){
chatInput.sendkeys('msg' + num); chatInput.sendkeys('msg' + num);
chatInput.sendkeys('{enter}'); chatInput.sendkeys('{enter}');
} }
setTimeout(function() { helper.waitFor(function(){
expect(chatText.children("p").length).to.be(messages); return chatText.children("p").length == messages;
}).done(function(){
$('#iframe-container iframe')[0].contentWindow.location.reload(); $('#iframe-container iframe')[0].contentWindow.location.reload();
done(); done();
}, 500); });
}); });
it("check initial message count", function(done) { it("checks initial message count", function(done) {
setTimeout(function() { helper.waitFor(function(){
// wait for the frame to load
var chrome$ = $('#iframe-container iframe')[0].contentWindow.$; var chrome$ = $('#iframe-container iframe')[0].contentWindow.$;
if(!chrome$) // page not fully loaded
return false;
var chatButton = chrome$("#chaticon"); var chatButton = chrome$("#chaticon");
chatButton.click(); chatButton.click();
var chatText = chrome$("#chattext"); var chatText = chrome$("#chattext");
return chatText.children("p").length == 101;
expect(chatText.children("p").length).to.be(101); }).done(done);
done();
}, 500);
}); });
it("load more messages", function(done) { it("loads more messages", function(done) {
var chrome$ = $('#iframe-container iframe')[0].contentWindow.$; var chrome$ = $('#iframe-container iframe')[0].contentWindow.$;
var chatButton = chrome$("#chaticon"); var chatButton = chrome$("#chaticon");
chatButton.click(); chatButton.click();
@ -48,13 +51,12 @@ describe("chat-load-messages", function(){
var loadMsgBtn = chrome$("#chatloadmessagesbutton"); var loadMsgBtn = chrome$("#chatloadmessagesbutton");
loadMsgBtn.click(); loadMsgBtn.click();
setTimeout(function() { helper.waitFor(function(){
expect(chatText.children("p").length).to.be(122); return chatText.children("p").length == 122;
done(); }).done(done);
}, 500);
}); });
it("btn vanishes", function(done) { it("checks for button vanishing", function(done) {
var chrome$ = $('#iframe-container iframe')[0].contentWindow.$; var chrome$ = $('#iframe-container iframe')[0].contentWindow.$;
var chatButton = chrome$("#chaticon"); var chatButton = chrome$("#chaticon");
chatButton.click(); chatButton.click();
@ -62,9 +64,8 @@ describe("chat-load-messages", function(){
var loadMsgBtn = chrome$("#chatloadmessagesbutton"); var loadMsgBtn = chrome$("#chatloadmessagesbutton");
loadMsgBtn.click(); loadMsgBtn.click();
setTimeout(function() { helper.waitFor(function(){
expect(loadMsgBtn.css('display')).to.be('none'); return loadMsgBtn.css('display') == 'none';
done(); }).done(done);
}, 200);
}); });
}); });