Skip to content

Commit

Permalink
working testing coverage for showChat
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnMcLear committed Mar 25, 2020
1 parent 42d9f58 commit 99107d3
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/frontend/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,25 @@ var helper = {};
helper.newPad = function(cb, padName){
//build opts object
var opts = {clearCookies: true}

if(typeof cb === 'function'){
opts.cb = cb
} else {
opts = _.defaults(cb, opts);
}

// if opts.params is set we manipulate the URL to include URL parameters IE ?foo=Bah.
if (opts.params) {
var encodedParams = "?" + $.param(opts.params);
}

//clear cookies
if(opts.clearCookies){
helper.clearCookies();
}

if(!padName)
padName = "FRONTEND_TEST_" + helper.randomString(20);
$iframe = $("<iframe src='/p/" + padName + "'></iframe>");
$iframe = $("<iframe src='/p/" + padName + (encodedParams || '') + "'></iframe>");

//clean up inner iframe references
helper.padChrome$ = helper.padOuter$ = helper.padInner$ = null;
Expand Down
37 changes: 37 additions & 0 deletions tests/frontend/specs/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,41 @@ describe("Chat messages and UI", function(){

done();
});

it("Checks showChat=false URL Parameter hides chat then when removed it shows chat", function(done) {
this.timeout(60000);
var inner$ = helper.padInner$;
var chrome$ = helper.padChrome$;

setTimeout(function(){ //give it a second to save the username on the server side
helper.newPad({ // get a new pad, but don't clear the cookies
clearCookies: false,
params:{
showChat: "false"
}, cb: function(){
var chrome$ = helper.padChrome$;
var chaticon = chrome$("#chaticon");
// chat should be hidden.
expect(chaticon.is(":visible")).to.be(false);


setTimeout(function(){ //give it a second to save the username on the server side
helper.newPad({ // get a new pad, but don't clear the cookies
clearCookies: false
, cb: function(){
var chrome$ = helper.padChrome$;
var chaticon = chrome$("#chaticon");
// chat should be visible.
expect(chaticon.is(":visible")).to.be(true);
done();
}
});
}, 1000);

}
});
}, 1000);

});

});

0 comments on commit 99107d3

Please sign in to comment.