summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authormluto <m@luto.at>2013-01-13 11:03:52 +0100
committermluto <m@luto.at>2013-01-13 11:03:52 +0100
commitc3dd433c990acbfb37a639b658dbb4d849d1620b (patch)
treed34f5486d643a85fca1eaa76c24da0837b3e11b0 /tests
parent176719b331c3b6880afc3c258a9a0865ee4af2c6 (diff)
downloadetherpad-lite-c3dd433c990acbfb37a639b658dbb4d849d1620b.zip
Fixed test-names, use waitFor instead of setTimeout
Diffstat (limited to 'tests')
-rw-r--r--tests/frontend/specs/chat_load_messages.js51
1 files changed, 26 insertions, 25 deletions
diff --git a/tests/frontend/specs/chat_load_messages.js b/tests/frontend/specs/chat_load_messages.js
index 71006413..6d702b9b 100644
--- a/tests/frontend/specs/chat_load_messages.js
+++ b/tests/frontend/specs/chat_load_messages.js
@@ -1,9 +1,9 @@
describe("chat-load-messages", function(){
- it("create pad", function(done) {
+ it("creates a pad", function(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 chrome$ = helper.padChrome$;
var chatButton = chrome$("#chaticon");
@@ -21,26 +21,29 @@ describe("chat-load-messages", function(){
chatInput.sendkeys('msg' + num);
chatInput.sendkeys('{enter}');
}
- setTimeout(function() {
- expect(chatText.children("p").length).to.be(messages);
+ helper.waitFor(function(){
+ return chatText.children("p").length == messages;
+ }).done(function(){
$('#iframe-container iframe')[0].contentWindow.location.reload();
done();
- }, 500);
+ });
});
- it("check initial message count", function(done) {
- setTimeout(function() {
- var chrome$ = $('#iframe-container iframe')[0].contentWindow.$;
- var chatButton = chrome$("#chaticon");
- chatButton.click();
- var chatText = chrome$("#chattext");
-
- expect(chatText.children("p").length).to.be(101);
- done();
- }, 500);
+ it("checks initial message count", function(done) {
+ helper.waitFor(function(){
+ // wait for the frame to load
+ var chrome$ = $('#iframe-container iframe')[0].contentWindow.$;
+ if(!chrome$) // page not fully loaded
+ return false;
+
+ var chatButton = chrome$("#chaticon");
+ chatButton.click();
+ var chatText = chrome$("#chattext");
+ return chatText.children("p").length == 101;
+ }).done(done);
});
- it("load more messages", function(done) {
+ it("loads more messages", function(done) {
var chrome$ = $('#iframe-container iframe')[0].contentWindow.$;
var chatButton = chrome$("#chaticon");
chatButton.click();
@@ -48,13 +51,12 @@ describe("chat-load-messages", function(){
var loadMsgBtn = chrome$("#chatloadmessagesbutton");
loadMsgBtn.click();
- setTimeout(function() {
- expect(chatText.children("p").length).to.be(122);
- done();
- }, 500);
+ helper.waitFor(function(){
+ return chatText.children("p").length == 122;
+ }).done(done);
});
- it("btn vanishes", function(done) {
+ it("checks for button vanishing", function(done) {
var chrome$ = $('#iframe-container iframe')[0].contentWindow.$;
var chatButton = chrome$("#chaticon");
chatButton.click();
@@ -62,9 +64,8 @@ describe("chat-load-messages", function(){
var loadMsgBtn = chrome$("#chatloadmessagesbutton");
loadMsgBtn.click();
- setTimeout(function() {
- expect(loadMsgBtn.css('display')).to.be('none');
- done();
- }, 200);
+ helper.waitFor(function(){
+ return loadMsgBtn.css('display') == 'none';
+ }).done(done);
});
});