mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-23 08:46:07 +08:00
848b4ef8a1
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
63 lines
1.9 KiB
JavaScript
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')
|
|
})
|
|
})
|
|
})
|