forked from octalmage/robotjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscreen.js
39 lines (33 loc) · 1.01 KB
/
screen.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
var robot = require('..');
var pixelColor, screenSize;
describe('Screen', () => {
it('Get pixel color.', function()
{
expect(pixelColor = robot.getPixelColor(5, 5)).toBeTruthy();
expect(pixelColor !== undefined).toBeTruthy();
expect(pixelColor.length === 6).toBeTruthy();
expect(/^[0-9A-F]{6}$/i.test(pixelColor)).toBeTruthy();
expect(function()
{
robot.getPixelColor(9999999999999, 9999999999999);
}).toThrowError(/outside the main screen/);
expect(function()
{
robot.getPixelColor(-1, -1);
}).toThrowError(/outside the main screen/);
expect(function()
{
robot.getPixelColor(0);
}).toThrowError(/Invalid number/);
expect(function()
{
robot.getPixelColor(1, 2, 3);
}).toThrowError(/Invalid number/);
});
it('Get screen size.', function()
{
expect(screenSize = robot.getScreenSize()).toBeTruthy();
expect(screenSize.width !== undefined).toBeTruthy();
expect(screenSize.height !== undefined).toBeTruthy();
});
});