import { expect } from 'chai' import * as selectors from '../../../js/modules/settings/selectors' import { IDomainObj } from '../../../js/modules/settings/interfaces' describe('settings selectors', () => { it('can select settings', () => { const testState = { settings: 'foo', } expect(selectors.settings(testState)).to.equal('foo') }) it('can select various notifications settings', () => { const testState = { settings: { notificationSentMessage: true, notificationVisitedSite: true, notificationClickedEmailLink: true, notificationOpenedEmail: true, notificationMuteList: [] as string[], }, } expect(selectors.notificationSentMessage(testState)).to.equal(true) expect(selectors.notificationVisitedSite(testState)).to.equal(true) expect(selectors.notificationClickedEmailLink(testState)).to.equal(true) expect(selectors.notificationOpenedEmail(testState)).to.equal(true) }) it('can select notificationMuteList', () => { const testState = { settings: { notificationSentMessage: true, notificationVisitedSite: true, notificationClickedEmailLink: true, notificationOpenedEmail: true, notificationMuteList: [] as string[], }, } expect(selectors.notificationMuteList(testState)).to.deep.equal([]) }) it('can get if emailOnMuteList', () => { const testState = { settings: { notificationSentMessage: true, notificationVisitedSite: true, notificationClickedEmailLink: true, notificationOpenedEmail: true, notificationMuteList: ['test1@drift.com', 'test2@drift.com'] as string[], }, } expect(selectors.emailOnMuteList(testState, 'test0@drift.com')).to.equal(false) expect(selectors.emailOnMuteList(testState, 'test1@drift.com')).to.equal(true) expect(selectors.emailOnMuteList(testState, 'test2@drift.com')).to.equal(true) }) it('can get if domainOnMuteList', () => { const testState = { settings: { domainMuteList: [ { domain: 'drift.com', date: Date.now()}, { domain: 'hotmail.com', date: Date.now() } ] as IDomainObj[], }, } expect(selectors.domainOnMuteList(testState, 'outlook.com')).to.equal(false) expect(selectors.domainOnMuteList(testState, 'drift.com')).to.equal(true) expect(selectors.domainOnMuteList(testState, 'hotmail.com')).to.equal(true) }) })