Skip to content

Commit

Permalink
Add new test to help identify keycode issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
octalmage committed Apr 17, 2016
1 parent bfcafa4 commit 3d8ba52
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions test/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,32 @@ var robot = require('..');

//TODO: Need tests for keyToggle, typeString, typeStringDelayed, and setKeyboardDelay.

test('Tap a key.', function(t)
test('Tap a key.', function(t)
{
t.plan(4);
t.ok(robot.keyTap("a") === 1, 'successfully tapped "a".');
t.ok(robot.keyTap("a", "control") === 1, 'successfully tapped "ctrl+a".');

t.throws(function()
{
robot.keyTap();
}, /Invalid number/, 'tap nothing.');

t.throws(function()
{
robot.keyTap();
}, /Invalid number/, 'tap "ctrl+a" with an extra argument.');
});

// This test won't fail if there's an issue, but it will help you identify an issue if ran locally.
test('Tap all keys', function(t)
{
var chars = 'abcdefghijklmnopqrstuvwxyz1234567890,./;\'[]\\'.split('');

for (var x in chars)
{
t.ok(robot.keyTap(chars[x]), 'tap ' + chars[x] + '.');
}

t.end();
});

0 comments on commit 3d8ba52

Please sign in to comment.