test('render div with props', t => { const root = t.context.root; const element = { type: 'div', props: { id: 'foo' } }; render(element, root); t.is(root.innerHTML, '<div id="foo"></div>'); });
test('stripFinalNewline in sync mode on failure', t => { const {stderr} = t.throws(() => { execa.sync('noop-throw', ['foo'], {stripFinalNewline: true}); }); t.is(stderr, 'foo'); });
test('replace div to span', t => { const root = t.context.root; let element = <div>Foo</div>; render(element, root); t.is(root.innerHTML, '<div>Foo</div>'); const prevChild = root.firstElementChild; element = <span>Foo</span>; render(element, root); t.is(root.innerHTML, '<span>Foo</span>'); const nextChild = root.firstElementChild; t.not(prevChild, nextChild); });
test('throw in finally bubbles up on error', async t => { const {message} = await t.throwsAsync(execa('exit', ['2']).finally(() => { throw new Error('called'); })); t.is(message, 'called'); });
test('input can be a Stream', async t => { const stream = new Stream.PassThrough(); stream.write('howdy'); stream.end(); const {stdout} = await execa('stdin', {input: stream}); t.is(stdout, 'howdy'); });
test('kill("SIGKILL") should terminate cleanly', async t => { const subprocess = execa('node', ['./test/fixtures/no-killable'], {stdio: ['ipc']}); await pEvent(subprocess, 'message'); subprocess.kill('SIGKILL'); const {signal} = await t.throwsAsync(subprocess); t.is(signal, 'SIGKILL'); });
test('render div with props', t => { const root = t.context.root; const element = <div id="foo" />; render(element, root); t.is(root.innerHTML, '<div id="foo"></div>'); });
test('reuse div', t => { const root = t.context.root; let element = <div>Foo</div>; render(element, root); t.is(root.innerHTML, '<div>Foo</div>'); const prevChild = root.firstElementChild; element = <div>Bar</div>; render(element, root); t.is(root.innerHTML, '<div>Bar</div>'); const nextChild = root.firstElementChild; t.is(prevChild, nextChild); });
test('`forceKillAfterTimeout: number` should kill after a timeout', async t => { const subprocess = execa('node', ['./test/fixtures/no-killable'], {stdio: ['ipc']}); await pEvent(subprocess, 'message'); subprocess.kill('SIGTERM', {forceKillAfterTimeout: 50}); const {signal} = await t.throwsAsync(subprocess); t.is(signal, 'SIGKILL'); });
test('`forceKillAfterTimeout: true` should kill after a timeout', async t => { const subprocess = execa('node', ['./test/fixtures/no-killable'], {stdio: ['ipc']}); await pEvent(subprocess, 'message'); subprocess.kill('SIGTERM', {forceKillAfterTimeout: true}); const {signal} = await t.throwsAsync(subprocess); t.is(signal, 'SIGKILL'); });
test('render jsx div', t => { const root = t.context.root; const element = <div />; render(element, root); t.is(root.innerHTML, '<div></div>'); });
test('kill() with no arguments should kill after a timeout', async t => { const subprocess = execa('node', ['./test/fixtures/no-killable'], {stdio: ['ipc']}); await pEvent(subprocess, 'message'); subprocess.kill(); const {signal} = await t.throwsAsync(subprocess); t.is(signal, 'SIGKILL'); });