mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-12 12:40:08 +08:00
9e3c3c14cd
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
57 lines
2.2 KiB
JavaScript
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);
|
|
})
|
|
})
|
|
})
|