Mailspring/internal_packages/composer-signature/spec/signature-store-spec.jsx
Annie 848b4ef8a1 fix(signatures): Added alias to accounts rendered in dropdown
Summary:
Extended default signatures to also be associated with aliases in the signature
preference page. Also fixed some styling with the signature dropdown button in its blurred
state on the popout composer.
fix(signatures): Fixed styling for signature compuser button on popout when blurred

test(signatures): Updated tests to support and cover extending signatures to alias

Test Plan: Modified existing tests to work with these changes

Reviewers: juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D3111
2016-07-21 11:33:15 -07:00

63 lines
1.9 KiB
JavaScript

/* eslint quote-props: 0 */
import {SignatureStore} from 'nylas-exports'
let SIGNATURES = {
'1': {
id: '1',
title: 'one',
body: 'first test signature!',
},
'2': {
id: '2',
title: 'two',
body: 'Here is my second sig!',
},
}
const DEFAULTS = {
'one@nylas.com': '2',
'two@nylas.com': '2',
'three@nylas.com': null,
}
describe('SignatureStore', function signatureStore() {
beforeEach(() => {
spyOn(NylasEnv.config, 'get').andCallFake(() => SIGNATURES)
spyOn(SignatureStore, '_saveSignatures').andCallFake(() => {
NylasEnv.config.set(`nylas.signatures`, SignatureStore.signatures)
})
spyOn(SignatureStore, 'signatureForEmail').andCallFake((email) => SIGNATURES[DEFAULTS[email]])
spyOn(SignatureStore, 'selectedSignature').andCallFake(() => SIGNATURES['1'])
SignatureStore.activate()
})
describe('signatureForAccountId', () => {
it('should return the default signature for that account', () => {
const titleForAccount1 = SignatureStore.signatureForEmail('one@nylas.com').title
expect(titleForAccount1).toEqual(SIGNATURES['2'].title)
const account2Def = SignatureStore.signatureForEmail('three@nylas.com')
expect(account2Def).toEqual(undefined)
})
})
describe('removeSignature', () => {
beforeEach(() => {
spyOn(NylasEnv.config, 'set').andCallFake((notImportant, newObject) => {
SIGNATURES = newObject
})
})
it('should remove the signature from our list of signatures', () => {
const toRemove = SIGNATURES[SignatureStore.selectedSignatureId]
SignatureStore._onRemoveSignature(toRemove)
expect(SIGNATURES['1']).toEqual(undefined)
})
it('should reset selectedSignatureId to a different signature', () => {
const toRemove = SIGNATURES[SignatureStore.selectedSignatureId]
SignatureStore._onRemoveSignature(toRemove)
expect(SignatureStore.selectedSignatureId).toNotEqual('1')
})
})
})