siesta-lite
Version:
Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers
91 lines (60 loc) • 2.23 kB
JavaScript
StartTest(function (t) {
t.it('Should not type any chars when Cmd/Ctrl are pressed', function (t) {
document.body.innerHTML = '<input type="text" id="foo"/>';
var isMac = Siesta.Recorder.Recorder.prototype.parseOS(navigator.platform) === 'MacOS';
t.chain(
{ click : '#foo' },
isMac ? { type : 'c', options : { metaKey : true } } :
{ type : 'c', options : { ctrlKey : true } },
function() {
t.expect($('#foo').val()).toBe('');
}
)
});
t.it('Typing F4', function (t) {
document.body.innerHTML = '<input type="text" id="foo1"/>';
t.chain(
{ click : '#foo1' },
{ type : '[F4]', target : '#foo1' },
function() {
t.expect($('#foo1').val()).toBe('');
}
)
});
t.it('Typing [something]', function (t) {
document.body.innerHTML = '<input type="text" id="foo2"/>';
t.chain(
{ click : '#foo2' },
{ type : '[test]', target : '#foo2' },
function() {
t.expect($('#foo2').val()).toBe('[test]');
}
)
});
t.it('Typing `[F3]` (as text)', function (t) {
document.body.innerHTML = '<input type="text" id="foo3"/>';
t.chain(
{ click : '#foo3' },
{ type : '[[F3]]', target : '#foo3' },
function (next) {
t.expect($('#foo3').val()).toBe('[F3]');
next()
},
{ type : '[[[F3]]]', target : '#foo3', clearExisting : true },
function (next) {
t.expect($('#foo3').val()).toBe('[[F3]]');
next()
},
{ type : '[[[BACKSPACE]]', target : '#foo3', clearExisting : true },
function (next) {
t.expect($('#foo3').val()).toBe('[[BACKSPACE]');
next()
},
{ type : '[[something]]', target : '#foo3', clearExisting : true },
function (next) {
t.expect($('#foo3').val()).toBe('[[something]]');
next()
}
)
});
})