-
-
Notifications
You must be signed in to change notification settings - Fork 584
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jonathan Dahan
committed
Mar 9, 2019
1 parent
7dd1b4d
commit 798b2d6
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}); |