From 2ff2f551ef8de3d913c716f9a1798e44b81247f2 Mon Sep 17 00:00:00 2001 From: Mark Bouslog Date: Mon, 4 Dec 2023 17:10:01 -0600 Subject: [PATCH] Refactor notification-section tests (#6972) --- .../notifications/notification-section.jsx | 4 ++- .../notification-section.spec.js | 26 ++++++++++++++----- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/app/pages/notifications/notification-section.jsx b/app/pages/notifications/notification-section.jsx index d5b320c54b..9fa43ef8e3 100644 --- a/app/pages/notifications/notification-section.jsx +++ b/app/pages/notifications/notification-section.jsx @@ -19,6 +19,7 @@ export default class NotificationSection extends Component { lastMeta: { }, loading: false, notificationData: [], + notifications: [], notificationsMap: { }, page: 1, project: null @@ -318,5 +319,6 @@ NotificationSection.contextTypes = { NotificationSection.defaultProps = { expanded: false, - toggleSection: () => {} + toggleSection: () => {}, + user: null }; diff --git a/app/pages/notifications/notification-section.spec.js b/app/pages/notifications/notification-section.spec.js index ad815ccbb6..d4bc6d28d3 100644 --- a/app/pages/notifications/notification-section.spec.js +++ b/app/pages/notifications/notification-section.spec.js @@ -138,12 +138,26 @@ describe('Notification Section', function() { const notificationsCounter = { update: sinon.stub() }; - wrapper = shallow( - , - { context: { notificationsCounter }, disableLifeCycleMethods: true } - ); - wrapper.setState({ notifications: newNotifications }); - wrapper.instance().markAsRead(newNotifications[0]); + + before(function () { + wrapper = shallow( + , + { + context: { notificationsCounter }, + disableLifeCycleMethods: true + } + ); + wrapper.setState({ + loading: false, + notificationData: [], + notifications: newNotifications + }); + wrapper.instance().markAsRead(newNotifications[0]); + }); it('should update read notification as read (delivered)', function () { assert.equal(newNotifications[0].update.calledWith({ delivered: true }), true);