siesta-lite
Version:
Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers
76 lines (51 loc) • 2.37 kB
JavaScript
StartTest(function (t) {
t.it('Simple HTML', function (t) {
t.expectGlobals('0', 'frame')
document.body.innerHTML = '<iframe width="512" height="384" frameborder=0 style="margin:0;padding:0" id="frame" src="html-pages/basic1.html"/>';
var recorder;
t.chain(
{
waitFor : function() {
var body = document.getElementById('frame').contentWindow.document.body
return body && body.innerHTML.match('div');
}
},
function(next) {
recorder = new Siesta.Recorder.ExtJS({ ignoreSynthetic : false });
recorder.attach(document.getElementById('frame').contentWindow);
recorder.start();
next();
},
{ click : [ 50, 50 ] },
{
waitFor : function() {
var body = document.getElementById('frame').contentWindow.document.body
return body && body.innerHTML.match('BAAAAAAAZ');
}
},
{ waitFor : 500 },
function (next) {
var events = recorder.getRecordedEvents();
t.is(events.length, 0, 'Recorder queue should be cleared on page load');
t.is(recorder.window, document.getElementById('frame').contentWindow, 'Recorder attached to new window object');
next()
},
{ click : [ 20, 20 ] },
{ waitFor : 500 },
function () {
var steps = recorder.getRecordedActionsAsSteps();
recorder.stop();
if (t.bowser.msedge) {
t.is(steps.length, 3)
t.isDeeply(steps[ 0 ], { waitForPageLoad : [], trigger : { action : "click", target : ".foo" }})
t.isDeeply(steps[ 1 ], { setWindowSize : [512, 384] })
t.isDeeply(steps[ 2 ], { action : "click", target : ".bar" })
} else {
t.is(steps.length, 2)
t.isDeeply(steps[ 0 ], { waitForPageLoad : [], trigger : { action : "click", target : ".foo" }})
t.isDeeply(steps[ 1 ], { action : "click", target : ".bar" })
}
}
)
})
})