Skip to content

Commit

Permalink
initial test
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Dahan committed Mar 9, 2019
1 parent 7dd1b4d commit 798b2d6
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/keypress.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use strict';
import React from 'react';
import test from 'ava';

import {render, useKeypress} from '..';

test.cb('letters work', t => {
t.plan(1);
const input = 'abcdefghijklmnopqrstuvwxyz';
// Process.stdin.isTTY = false;
const hits = '';
const KeypressTest = () => {
useKeypress((str, _) => {
hits.push(str);
if (str === 'z') {
t.deepEqual(hits, input);
t.end();
}
});
return null;
};

render(<KeypressTest/>);
for (const letter of input.split('')) {
process.stdin.push(Buffer.from(letter));
}

process.stdin.emit('end');
});

0 comments on commit 798b2d6

Please sign in to comment.