api-notification-spec.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. const chai = require('chai')
  2. const dirtyChai = require('dirty-chai')
  3. const { expect } = chai
  4. chai.use(dirtyChai)
  5. const { Notification } = require('electron').remote
  6. describe('Notification module', () => {
  7. it('inits, gets and sets basic string properties correctly', () => {
  8. const n = new Notification({
  9. title: 'title',
  10. subtitle: 'subtitle',
  11. body: 'body',
  12. replyPlaceholder: 'replyPlaceholder',
  13. sound: 'sound',
  14. closeButtonText: 'closeButtonText'
  15. })
  16. expect(n.title).to.equal('title')
  17. n.title = 'title1'
  18. expect(n.title).to.equal('title1')
  19. expect(n.subtitle).equal('subtitle')
  20. n.subtitle = 'subtitle1'
  21. expect(n.subtitle).equal('subtitle1')
  22. expect(n.body).to.equal('body')
  23. n.body = 'body1'
  24. expect(n.body).to.equal('body1')
  25. expect(n.replyPlaceholder).to.equal('replyPlaceholder')
  26. n.replyPlaceholder = 'replyPlaceholder1'
  27. expect(n.replyPlaceholder).to.equal('replyPlaceholder1')
  28. expect(n.sound).to.equal('sound')
  29. n.sound = 'sound1'
  30. expect(n.sound).to.equal('sound1')
  31. expect(n.closeButtonText).to.equal('closeButtonText')
  32. n.closeButtonText = 'closeButtonText1'
  33. expect(n.closeButtonText).to.equal('closeButtonText1')
  34. })
  35. it('inits, gets and sets basic boolean properties correctly', () => {
  36. const n = new Notification({
  37. silent: true,
  38. hasReply: true
  39. })
  40. expect(n.silent).to.be.true()
  41. n.silent = false
  42. expect(n.silent).to.be.false()
  43. expect(n.hasReply).to.be.true()
  44. n.hasReply = false
  45. expect(n.hasReply).to.be.false()
  46. })
  47. it('inits, gets and sets actions correctly', () => {
  48. const n = new Notification({
  49. actions: [
  50. {
  51. type: 'button',
  52. text: '1'
  53. }, {
  54. type: 'button',
  55. text: '2'
  56. }
  57. ]
  58. })
  59. expect(n.actions.length).to.equal(2)
  60. expect(n.actions[0].type).to.equal('button')
  61. expect(n.actions[0].text).to.equal('1')
  62. expect(n.actions[1].type).to.equal('button')
  63. expect(n.actions[1].text).to.equal('2')
  64. n.actions = [
  65. {
  66. type: 'button',
  67. text: '3'
  68. }, {
  69. type: 'button',
  70. text: '4'
  71. }
  72. ]
  73. expect(n.actions.length).to.equal(2)
  74. expect(n.actions[0].type).to.equal('button')
  75. expect(n.actions[0].text).to.equal('3')
  76. expect(n.actions[1].type).to.equal('button')
  77. expect(n.actions[1].text).to.equal('4')
  78. })
  79. // TODO(sethlu): Find way to test init with notification icon?
  80. })