api-notification-spec.js 2.2 KB

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