Skip to content

Commit

Permalink
Various improvments of the helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Pita committed Nov 3, 2012
1 parent ebef2d2 commit cd368b5
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions tests/frontend/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,24 @@ var helper = {};
return win.$;
}

helper.newPad = function(cb){
helper.clearCookies = function(){
window.document.cookie = "";
}

helper.newPad = function(){
//build opts object
var opts = {clearCookies: true}
if(typeof arguments[0] === 'function'){
opts.cb = arguments[0]
} else {
opts = _.defaults(arguments[0], opts);
}

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

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

Expand All @@ -69,8 +86,13 @@ var helper = {};
helper.padChrome$ = getFrameJQuery( $('#iframe-container iframe'));
helper.padOuter$ = getFrameJQuery(helper.padChrome$('iframe.[name="ace_outer"]'));
helper.padInner$ = getFrameJQuery( helper.padOuter$('iframe.[name="ace_inner"]'));

//disable all animations, this makes tests faster and easier
helper.padChrome$.fx.off = true;
helper.padOuter$.fx.off = true;
helper.padInner$.fx.off = true;

cb();
opts.cb();
}).fail(function(){
throw new Error("Pad never loaded");
});
Expand Down

0 comments on commit cd368b5

Please sign in to comment.