api-screen-spec.ts 3.2 KB

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