Skip to content

Commit

Permalink
Better tests for getPixelColor.
Browse files Browse the repository at this point in the history
  • Loading branch information
octalmage committed Jan 8, 2016
1 parent b1f2852 commit d8cbb74
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion test/screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,31 @@ var pixelColor, screenSize;

test('Get pixel color.', function(t)
{
t.plan(4);
t.plan(8);
t.ok(pixelColor = robot.getPixelColor(5, 5), 'successfully got pixel color.');
t.ok(pixelColor !== undefined, 'pixelColor is a valid value.');
t.ok(pixelColor.length === 6, 'pixelColor is the correct length.');
t.ok(/^[0-9A-F]{6}$/i.test(pixelColor), "pixelColor is valid hex.");

t.throws(function()
{
robot.getPixelColor(9999999999999, 9999999999999);
}, /outside the main screen/, 'get color of pixel (9999999999999, 9999999999999).');

t.throws(function()
{
robot.getPixelColor(-1, -1);
}, /outside the main screen/, 'get color of pixel (-1, -1).');

t.throws(function()
{
robot.getPixelColor(0);
}, /Invalid number/, 'get color of pixel (0).');

t.throws(function()
{
robot.getPixelColor(1, 2, 3);
}, /Invalid number/, 'get color of pixel (1, 2, 3).');
});

test('Get screen size.', function(t)
Expand Down

0 comments on commit d8cbb74

Please sign in to comment.