siesta-lite
Version:
Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers
62 lines (46 loc) • 1.71 kB
JavaScript
StartTest(function (t) {
document.body.innerHTML = '<input id="foo" type="text" />';
var recorder = new Siesta.Recorder.ExtJS({ ignoreSynthetic : false });
recorder.attach(window);
var el = t.$('#foo')[0];
el.focus();
function verifyChar(test, char, keyEventInfo) {
recorder.clear();
recorder.start();
test.type(null, char, function () {
recorder.stop();
var recordedActions = recorder.getRecordedActions()
test.is(recordedActions.length, 1);
if (recordedActions.length) {
test.is(recordedActions[0].action, 'type');
test.is(recordedActions[0].value, char);
}
})
}
t.chain(
// see https://code.google.com/p/selenium/issues/detail?id=4801
// also https://support.saucelabs.com/customer/en/portal/private/cases/31771
t.browser.safari && t.project.isAutomated
?
{ waitFor : function () { return el == document.activeElement } }
:
{ waitForSelector : 'input:focus' },
function () {
t.it('should record "a"', function (t) {
verifyChar(t, 'a');
})
t.it('should record "."', function (t) {
verifyChar(t, '.');
});
t.it('should record "-"', function (t) {
verifyChar(t, '-');
});
t.it('should record RETURN', function (t) {
verifyChar(t, '[ENTER]');
});
t.it('should record arrow RIGHT', function (t) {
verifyChar(t, '[ARROWRIGHT]');
});
}
)
})