Skip to content

Commit

Permalink
Spec - Uniqe notifications (#23)
Browse files Browse the repository at this point in the history
Should not add notification if it already exists in the notification system based on the uid
see #17
  • Loading branch information
gor181 committed Dec 7, 2016
1 parent c441b51 commit 0afd77a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/__tests__/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,31 @@ describe('NotificationsComponent', () => {
expect(wrapper.html()).to.have.string(notification.message);
});

it('should not add notification if it already exists based on the uid', () => {
const wrapper = mountComponent();

wrapper.setProps({
notifications: [
{ ...notification, uid: 1, title: '1st' },
{ ...notification, uid: 2, title: '2nd' },
{ ...notification, uid: 3, title: '3rd' },
{ ...notification, uid: 1, title: '4th' },
{ ...notification, uid: 2, title: '5th' },
{ ...notification, uid: 3, title: '6th' }
]
});

const html = wrapper.html();

expect(html).to.have.string('1st');
expect(html).to.have.string('2nd');
expect(html).to.have.string('3rd');

expect(html).not.to.have.string('4th');
expect(html).not.to.have.string('5th');
expect(html).not.to.have.string('6th');
});

it('calls onRemove once the notification is auto dismissed', (done) => {
const wrapper = mountComponent();
const onRemove = sinon.spy();
Expand Down

0 comments on commit 0afd77a

Please sign in to comment.