api-notification-spec.ts 2.5 KB

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