|
1 | | -const assert = require('assert') |
| 1 | +const { expect } = require('chai') |
2 | 2 | const { screen } = require('electron').remote |
3 | 3 |
|
4 | 4 | describe('screen module', () => { |
5 | 5 | describe('screen.getCursorScreenPoint()', () => { |
6 | 6 | it('returns a point object', () => { |
7 | 7 | const point = screen.getCursorScreenPoint() |
8 | | - assert.strictEqual(typeof point.x, 'number') |
9 | | - assert.strictEqual(typeof point.y, 'number') |
| 8 | + expect(point.x).to.be.a('number') |
| 9 | + expect(point.y).to.be.a('number') |
10 | 10 | }) |
11 | 11 | }) |
12 | 12 |
|
13 | 13 | describe('screen.getPrimaryDisplay()', () => { |
14 | 14 | it('returns a display object', () => { |
15 | 15 | const display = screen.getPrimaryDisplay() |
16 | | - assert.strictEqual(typeof display.scaleFactor, 'number') |
17 | | - assert(display.size.width > 0) |
18 | | - assert(display.size.height > 0) |
| 16 | + expect(display).to.be.an('object') |
| 17 | + }) |
| 18 | + |
| 19 | + it('has the correct non-object properties', function () { |
| 20 | + if (process.platform === 'linux') this.skip() |
| 21 | + const display = screen.getPrimaryDisplay() |
| 22 | + |
| 23 | + expect(display).to.have.a.property('scaleFactor').that.is.a('number') |
| 24 | + expect(display).to.have.a.property('id').that.is.a('number') |
| 25 | + expect(display).to.have.a.property('rotation').that.is.a('number') |
| 26 | + expect(display).to.have.a.property('touchSupport').that.is.a('string') |
| 27 | + expect(display).to.have.a.property('accelerometerSupport').that.is.a('string') |
| 28 | + expect(display).to.have.a.property('internal').that.is.a('boolean') |
| 29 | + expect(display).to.have.a.property('monochrome').that.is.a('boolean') |
| 30 | + expect(display).to.have.a.property('depthPerComponent').that.is.a('number') |
| 31 | + expect(display).to.have.a.property('colorDepth').that.is.a('number') |
| 32 | + }) |
| 33 | + |
| 34 | + it('has a size object property', function () { |
| 35 | + if (process.platform === 'linux') this.skip() |
| 36 | + const display = screen.getPrimaryDisplay() |
| 37 | + |
| 38 | + expect(display).to.have.a.property('size').that.is.an('object') |
| 39 | + const size = display.size |
| 40 | + expect(size).to.have.a.property('width').that.is.greaterThan(0) |
| 41 | + expect(size).to.have.a.property('height').that.is.greaterThan(0) |
| 42 | + }) |
| 43 | + |
| 44 | + it('has a workAreaSize object property', function () { |
| 45 | + if (process.platform === 'linux') this.skip() |
| 46 | + const display = screen.getPrimaryDisplay() |
| 47 | + |
| 48 | + expect(display).to.have.a.property('workAreaSize').that.is.an('object') |
| 49 | + const workAreaSize = display.workAreaSize |
| 50 | + expect(workAreaSize).to.have.a.property('width').that.is.greaterThan(0) |
| 51 | + expect(workAreaSize).to.have.a.property('height').that.is.greaterThan(0) |
| 52 | + }) |
| 53 | + |
| 54 | + it('has a bounds object property', function () { |
| 55 | + if (process.platform === 'linux') this.skip() |
| 56 | + const display = screen.getPrimaryDisplay() |
| 57 | + |
| 58 | + expect(display).to.have.a.property('bounds').that.is.an('object') |
| 59 | + const bounds = display.bounds |
| 60 | + expect(bounds).to.have.a.property('x').that.is.a('number') |
| 61 | + expect(bounds).to.have.a.property('y').that.is.a('number') |
| 62 | + expect(bounds).to.have.a.property('width').that.is.greaterThan(0) |
| 63 | + expect(bounds).to.have.a.property('height').that.is.greaterThan(0) |
| 64 | + }) |
| 65 | + |
| 66 | + it('has a workArea object property', function () { |
| 67 | + const display = screen.getPrimaryDisplay() |
| 68 | + |
| 69 | + expect(display).to.have.a.property('workArea').that.is.an('object') |
| 70 | + const workArea = display.workArea |
| 71 | + expect(workArea).to.have.a.property('x').that.is.a('number') |
| 72 | + expect(workArea).to.have.a.property('y').that.is.a('number') |
| 73 | + expect(workArea).to.have.a.property('width').that.is.greaterThan(0) |
| 74 | + expect(workArea).to.have.a.property('height').that.is.greaterThan(0) |
19 | 75 | }) |
20 | 76 | }) |
21 | 77 | }) |
0 commit comments