Mailspring/internal_packages/notifications/spec/disabled-mail-rules-notif-spec.jsx
Halla Moore 9e3c3c14cd feat(sidebar-notifs) Create sidebar notifications to replace old bars
Summary:
Move the old bar notifications to the sidebar, and only display one notification
at a time using a priority-rating system. Remove all of the old notification
infrastructure.

Test Plan: Added specs, also reproduced notifications locally

Reviewers: bengotow

Reviewed By: bengotow

Subscribers: juan

Differential Revision: https://phab.nylas.com/D3310
2016-10-04 08:08:23 -07:00

57 lines
2.2 KiB
JavaScript

import {mount} from 'enzyme';
import {React, AccountStore, Account, Actions, MailRulesStore} from 'nylas-exports';
import DisabledMailRulesNotification from '../lib/items/disabled-mail-rules-notif';
describe("DisabledMailRulesNotification", function DisabledMailRulesNotifTests() {
beforeEach(() => {
spyOn(AccountStore, 'accounts').andReturn([
new Account({id: 'A', syncState: 'running', emailAddress: '123@gmail.com'}),
])
})
describe("When there is one disabled mail rule", () => {
beforeEach(() => {
spyOn(MailRulesStore, "disabledRules").andReturn([{accountId: 'A'}])
this.notif = mount(<DisabledMailRulesNotification />)
})
it("displays a notification", () => {
expect(this.notif.find('.notification').isEmpty()).toEqual(false);
})
it("allows users to open the preferences", () => {
spyOn(Actions, "switchPreferencesTab")
spyOn(Actions, "openPreferences")
this.notif.find('#action-0').simulate('click');
expect(Actions.switchPreferencesTab).toHaveBeenCalledWith('Mail Rules', {accountId: 'A'})
expect(Actions.openPreferences).toHaveBeenCalled();
})
});
describe("When there are multiple disabled mail rules", () => {
beforeEach(() => {
spyOn(MailRulesStore, "disabledRules").andReturn([{accountId: 'A'},
{accountId: 'A'}])
this.notif = mount(<DisabledMailRulesNotification />)
})
it("displays a notification", () => {
expect(this.notif.find('.notification').isEmpty()).toEqual(false);
})
it("allows users to open the preferences", () => {
spyOn(Actions, "switchPreferencesTab")
spyOn(Actions, "openPreferences")
this.notif.find('#action-0').simulate('click');
expect(Actions.switchPreferencesTab).toHaveBeenCalledWith('Mail Rules', {accountId: 'A'})
expect(Actions.openPreferences).toHaveBeenCalled();
})
});
describe("When there are no disabled mail rules", () => {
beforeEach(() => {
spyOn(MailRulesStore, "disabledRules").andReturn([])
this.notif = mount(<DisabledMailRulesNotification />)
})
it("does not display a notification", () => {
expect(this.notif.find('.notification').isEmpty()).toEqual(true);
})
})
})