logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://anongit.hacktivis.me/git/pleroma-fe.git/

notification_utils.spec.js (2226B)


  1. import * as NotificationUtils from 'src/services/notification_utils/notification_utils.js'
  2. describe('NotificationUtils', () => {
  3. describe('filteredNotificationsFromStore', () => {
  4. it('should return sorted notifications with configured types', () => {
  5. const store = {
  6. state: {
  7. notifications: {
  8. data: [
  9. {
  10. id: 1,
  11. action: { id: '1' },
  12. type: 'like'
  13. },
  14. {
  15. id: 2,
  16. action: { id: '2' },
  17. type: 'mention'
  18. },
  19. {
  20. id: 3,
  21. action: { id: '3' },
  22. type: 'repeat'
  23. }
  24. ]
  25. }
  26. },
  27. getters: {
  28. mergedConfig: {
  29. notificationVisibility: {
  30. likes: true,
  31. repeats: true,
  32. mentions: false
  33. }
  34. }
  35. }
  36. }
  37. const expected = [
  38. {
  39. action: { id: '3' },
  40. id: 3,
  41. type: 'repeat'
  42. },
  43. {
  44. action: { id: '1' },
  45. id: 1,
  46. type: 'like'
  47. }
  48. ]
  49. expect(NotificationUtils.filteredNotificationsFromStore(store)).to.eql(expected)
  50. })
  51. })
  52. describe('unseenNotificationsFromStore', () => {
  53. it('should return only notifications not marked as seen', () => {
  54. const store = {
  55. state: {
  56. notifications: {
  57. data: [
  58. {
  59. action: { id: '1' },
  60. type: 'like',
  61. seen: false
  62. },
  63. {
  64. action: { id: '2' },
  65. type: 'mention',
  66. seen: true
  67. }
  68. ]
  69. }
  70. },
  71. getters: {
  72. mergedConfig: {
  73. notificationVisibility: {
  74. likes: true,
  75. repeats: true,
  76. mentions: false
  77. }
  78. }
  79. }
  80. }
  81. const expected = [
  82. {
  83. action: { id: '1' },
  84. type: 'like',
  85. seen: false
  86. }
  87. ]
  88. expect(NotificationUtils.unseenNotificationsFromStore(store)).to.eql(expected)
  89. })
  90. })
  91. })