From 176719b331c3b6880afc3c258a9a0865ee4af2c6 Mon Sep 17 00:00:00 2001 From: mluto Date: Sun, 13 Jan 2013 10:39:13 +0100 Subject: Added tests --- tests/frontend/specs/chat_load_messages.js | 70 ++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 tests/frontend/specs/chat_load_messages.js diff --git a/tests/frontend/specs/chat_load_messages.js b/tests/frontend/specs/chat_load_messages.js new file mode 100644 index 00000000..71006413 --- /dev/null +++ b/tests/frontend/specs/chat_load_messages.js @@ -0,0 +1,70 @@ +describe("chat-load-messages", function(){ + it("create pad", function(done) { + helper.newPad(done); + }); + + it("add a lot of messages", function(done) { + var inner$ = helper.padInner$; + var chrome$ = helper.padChrome$; + var chatButton = chrome$("#chaticon"); + chatButton.click(); + var chatInput = chrome$("#chatinput"); + var chatText = chrome$("#chattext"); + + var messages = 140; + for(var i=1; i <= messages; i++) { + var num = ''+i; + if(num.length == 1) + num = '00'+num; + if(num.length == 2) + num = '0'+num; + chatInput.sendkeys('msg' + num); + chatInput.sendkeys('{enter}'); + } + setTimeout(function() { + expect(chatText.children("p").length).to.be(messages); + $('#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("load more messages", function(done) { + var chrome$ = $('#iframe-container iframe')[0].contentWindow.$; + var chatButton = chrome$("#chaticon"); + chatButton.click(); + var chatText = chrome$("#chattext"); + var loadMsgBtn = chrome$("#chatloadmessagesbutton"); + + loadMsgBtn.click(); + setTimeout(function() { + expect(chatText.children("p").length).to.be(122); + done(); + }, 500); + }); + + it("btn vanishes", function(done) { + var chrome$ = $('#iframe-container iframe')[0].contentWindow.$; + var chatButton = chrome$("#chaticon"); + chatButton.click(); + var chatText = chrome$("#chattext"); + var loadMsgBtn = chrome$("#chatloadmessagesbutton"); + + loadMsgBtn.click(); + setTimeout(function() { + expect(loadMsgBtn.css('display')).to.be('none'); + done(); + }, 200); + }); +}); -- cgit v1.2.3