forked from electron/electron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi-screen-spec.ts
89 lines (76 loc) · 3.77 KB
/
api-screen-spec.ts
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import { expect } from 'chai';
import { screen } from 'electron/main';
import { ifit } from './lib/spec-helpers';
describe('screen module', () => {
describe('methods reassignment', () => {
it('works for a selected method', () => {
const originalFunction = screen.getPrimaryDisplay;
try {
(screen as any).getPrimaryDisplay = () => null;
expect(screen.getPrimaryDisplay()).to.be.null();
} finally {
screen.getPrimaryDisplay = originalFunction;
}
});
});
describe('screen.getCursorScreenPoint()', () => {
it('returns a point object', () => {
const point = screen.getCursorScreenPoint();
expect(point.x).to.be.a('number');
expect(point.y).to.be.a('number');
});
});
describe('screen.getPrimaryDisplay()', () => {
it('returns a display object', () => {
const display = screen.getPrimaryDisplay();
expect(display).to.be.an('object');
});
ifit(process.platform !== 'linux')('has the correct non-object properties', function () {
const display = screen.getPrimaryDisplay();
expect(display).to.have.property('scaleFactor').that.is.a('number');
expect(display).to.have.property('id').that.is.a('number');
expect(display).to.have.property('label').that.is.a('string');
expect(display).to.have.property('rotation').that.is.a('number');
expect(display).to.have.property('touchSupport').that.is.a('string');
expect(display).to.have.property('accelerometerSupport').that.is.a('string');
expect(display).to.have.property('internal').that.is.a('boolean');
expect(display).to.have.property('monochrome').that.is.a('boolean');
expect(display).to.have.property('depthPerComponent').that.is.a('number');
expect(display).to.have.property('colorDepth').that.is.a('number');
expect(display).to.have.property('colorSpace').that.is.a('string');
expect(display).to.have.property('displayFrequency').that.is.a('number');
});
ifit(process.platform !== 'linux')('has a size object property', function () {
const display = screen.getPrimaryDisplay();
expect(display).to.have.property('size').that.is.an('object');
const size = display.size;
expect(size).to.have.property('width').that.is.greaterThan(0);
expect(size).to.have.property('height').that.is.greaterThan(0);
});
ifit(process.platform !== 'linux')('has a workAreaSize object property', function () {
const display = screen.getPrimaryDisplay();
expect(display).to.have.property('workAreaSize').that.is.an('object');
const workAreaSize = display.workAreaSize;
expect(workAreaSize).to.have.property('width').that.is.greaterThan(0);
expect(workAreaSize).to.have.property('height').that.is.greaterThan(0);
});
ifit(process.platform !== 'linux')('has a bounds object property', function () {
const display = screen.getPrimaryDisplay();
expect(display).to.have.property('bounds').that.is.an('object');
const bounds = display.bounds;
expect(bounds).to.have.property('x').that.is.a('number');
expect(bounds).to.have.property('y').that.is.a('number');
expect(bounds).to.have.property('width').that.is.greaterThan(0);
expect(bounds).to.have.property('height').that.is.greaterThan(0);
});
it('has a workArea object property', function () {
const display = screen.getPrimaryDisplay();
expect(display).to.have.property('workArea').that.is.an('object');
const workArea = display.workArea;
expect(workArea).to.have.property('x').that.is.a('number');
expect(workArea).to.have.property('y').that.is.a('number');
expect(workArea).to.have.property('width').that.is.greaterThan(0);
expect(workArea).to.have.property('height').that.is.greaterThan(0);
});
});
});