Skip to content

Instantly share code, notes, and snippets.

@agnanachandran
Created February 15, 2018 21:50
Show Gist options
  • Select an option

  • Save agnanachandran/08d887843230c08536ab223ba9104f24 to your computer and use it in GitHub Desktop.

Select an option

Save agnanachandran/08d887843230c08536ab223ba9104f24 to your computer and use it in GitHub Desktop.

Revisions

  1. agnanachandran created this gist Feb 15, 2018.
    18 changes: 18 additions & 0 deletions notifications_store_test.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    describe('Notifications Store', () => {
    it('should have read and unread notifications', () => {
    const readNotification = new Notification('1', 'read', 100, true);
    const unreadNotification = new Notification('2', 'unread', 101, false);
    const unreadNotification2 = new Notification('3', 'unread2', 102, false);
    const notifications = [readNotification, unreadNotification, unreadNotification2];

    const notificationsStore = NotificationsStore.initialize(notifications);

    expect(notificationsStore.unreadNotifications).to.have.length(2);
    // Ensure unread notifications are in reverse chronological order by creation time
    expect(notificationsStore.unreadNotifications[0].time).to.equal(102);
    expect(notificationsStore.unreadNotifications[1].time).to.equal(101);

    expect(notificationsStore.readNotifications).to.have.length(1);
    expect(notificationsStore.readNotifications[0].id).to.equal('1');
    });
    });