Skip to content

Commit

Permalink
comment out keypress test
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Dahan committed Mar 11, 2019
1 parent 7c5e16b commit 0735470
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 4 additions & 0 deletions test/exit.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,14 @@ test('exit on unmount() with raw mode', async t => {
t.true(output.includes('exited'));
});

// Uncomment when there is a way for ava to pass a handle to stdin/stdout nicely
// See https://github.com/avajs/ava/pull/2011/ as an example
/*
test('handles keypresses', async t => {
const output = await run('handles-keypresses');
t.true(output.includes('exited'));
});
*/

test.cb('don\'t exit while raw mode is active', t => {
const term = spawn('node', ['./fixtures/run', './exit-double-raw-mode'], {
Expand Down
13 changes: 7 additions & 6 deletions test/fixtures/handles-keypresses.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ const React = require('react');
const {render, useKeypress} = require('../..');

const input = 'abcdefghijklmnopqrstuvwxyz';
// Process.stdin.isTTY = false;

const hits = '';
const KeypressTest = () => {
useKeypress((str, _) => {
hits.push(str);
if (str === 'z') {
strictEqual(hits, input);
}
});
return null;
};
Expand All @@ -24,8 +21,12 @@ input.split('').forEach(letter => {
app.waitUntilExit().then(() => console.log('exited'));

setInterval(() => {
throw new Error(`${hits}`);
if (hits.length > 25) {
if (hits.length === input.length) {
strictEqual(hits, input);
app.unmount();
}
}, 500);

setTimeout(() => {
throw new Error('Timed out');
}, 5000);

0 comments on commit 0735470

Please sign in to comment.