Skip to content

Commit d8cbb74

Browse files
committed
Better tests for getPixelColor.
1 parent b1f2852 commit d8cbb74

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

test/screen.js

+21-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,31 @@ var pixelColor, screenSize;
44

55
test('Get pixel color.', function(t)
66
{
7-
t.plan(4);
7+
t.plan(8);
88
t.ok(pixelColor = robot.getPixelColor(5, 5), 'successfully got pixel color.');
99
t.ok(pixelColor !== undefined, 'pixelColor is a valid value.');
1010
t.ok(pixelColor.length === 6, 'pixelColor is the correct length.');
1111
t.ok(/^[0-9A-F]{6}$/i.test(pixelColor), "pixelColor is valid hex.");
12+
13+
t.throws(function()
14+
{
15+
robot.getPixelColor(9999999999999, 9999999999999);
16+
}, /outside the main screen/, 'get color of pixel (9999999999999, 9999999999999).');
17+
18+
t.throws(function()
19+
{
20+
robot.getPixelColor(-1, -1);
21+
}, /outside the main screen/, 'get color of pixel (-1, -1).');
22+
23+
t.throws(function()
24+
{
25+
robot.getPixelColor(0);
26+
}, /Invalid number/, 'get color of pixel (0).');
27+
28+
t.throws(function()
29+
{
30+
robot.getPixelColor(1, 2, 3);
31+
}, /Invalid number/, 'get color of pixel (1, 2, 3).');
1232
});
1333

1434
test('Get screen size.', function(t)

0 commit comments

Comments
 (0)