Skip to content

Commit

Permalink
Refactor notification-section tests (#6972)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcbouslog authored Dec 4, 2023
1 parent 304aa9a commit 2ff2f55
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
4 changes: 3 additions & 1 deletion app/pages/notifications/notification-section.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default class NotificationSection extends Component {
lastMeta: { },
loading: false,
notificationData: [],
notifications: [],
notificationsMap: { },
page: 1,
project: null
Expand Down Expand Up @@ -318,5 +319,6 @@ NotificationSection.contextTypes = {

NotificationSection.defaultProps = {
expanded: false,
toggleSection: () => {}
toggleSection: () => {},
user: null
};
26 changes: 20 additions & 6 deletions app/pages/notifications/notification-section.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,26 @@ describe('Notification Section', function() {
const notificationsCounter = {
update: sinon.stub()
};
wrapper = shallow(
<NotificationSection expanded={true} />,
{ context: { notificationsCounter }, disableLifeCycleMethods: true }
);
wrapper.setState({ notifications: newNotifications });
wrapper.instance().markAsRead(newNotifications[0]);

before(function () {
wrapper = shallow(
<NotificationSection
expanded={true}
section="zooniverse"
user={{ id: '1' }}
/>,
{
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);
Expand Down

0 comments on commit 2ff2f55

Please sign in to comment.