UNPKG

siesta-lite

Version:

Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers

121 lines (83 loc) 3.21 kB
StartTest(function (t) { t.expectGlobals('0', '1', '2') t.it('Should fire change after tabbing out of field after value changed using BACKSPACE', function (t) { document.body.innerHTML = '<input value="foo"/>'; t.firesOnce('input', 'change'); t.chain( { click : 'input' }, { type : '[BACKSPACE][TAB]' }, function(){ t.hasValue('input', 'fo'); } ); }); t.it('Should fire change after tabbing out of field after value changed using DELETE', function (t) { document.body.innerHTML = '<input value="foo"/>'; t.firesOnce('input', 'change'); t.chain( { click : 'input' }, function(next){ t.setCaretPosition(t.query('input')[0], 0); next(); }, { type : '[DELETE][TAB]' }, function(){ t.hasValue('input', 'oo'); } ); }); t.describe('Should fire `change` event on focus move, for nested iframe', async t => { let DOC t.beforeEach(async t => { const iframe = document.createElement('iframe') iframe.src = 'about:blank' iframe.style.width = '300px' iframe.style.height = '200px' await new Promise(resolve => { iframe.addEventListener('load', resolve) document.body.appendChild(iframe) }) DOC = iframe.contentWindow.document }) t.it('Should fire `change` event on regular blur', async t => { DOC.body.innerHTML = '<input id="input" value=""/>'; const input = DOC.getElementById('input') t.firesOnce(input, 'change'); t.chain( { click : input }, { type : 'some[TAB]' }, function(){ t.hasValue(input, 'some'); } ); }) t.it('Should fire `change` event after tabbing out of field after value changed using BACKSPACE', async t => { DOC.body.innerHTML = '<input id="input" value="foo"/>'; const input = DOC.getElementById('input') t.firesOnce(input, 'change'); t.chain( { click : input }, { type : '[BACKSPACE][TAB]' }, function(){ t.hasValue(input, 'fo'); } ); }) t.it('Should fire `change` event after tabbing out of field after value changed using DELETE', function (t) { DOC.body.innerHTML = '<input id="input" value="foo"/>'; const input = DOC.getElementById('input') t.firesOnce(input, 'change'); t.chain( { click : input }, function(next){ t.setCaretPosition(input, 0); next(); }, { type : '[DELETE][TAB]' }, function(){ t.hasValue(input, 'oo'); } ); }); }); })