mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-22 16:09:14 +08:00
39e5a2ee96
Summary: Refactored signature preferences page to allow more signatures than the previous 1-1 mapping for signatures and accounts. Created a multi select dropdown of the accounts for which a certain signature is set as default for. Added a button into the draft header From field to toggle between saved signatures. refactor(signatures): Add basic add/remove capabilities to static refactor(signatures): Hooked up signature actions and signature store for basic functionality fix(signatures): Cleaned up signature store and started on multiselectdropdown fix(signatures): Add multi signature toggle select to multiselect dropdown build(signatures): Built framework for multiselect dropdown build(signatures): Toggle button functionality for dropdown build(signatures): Build multi select from components and add debounce refactor(signatures): Move signature actions and signature store into flux fix(signatures): Styled composer signatures button/dropdown and fixed preferences checkmarks build(signatures): Finish main functionality, about to refactor composer signature button into injected component fix(signatures): Changed position styles fix(signatures): Fixed background color for dropdown button when blurred build(signatures): Began to write tests for signatures store, preferences and dropdown Test Plan: Wrote tests for preferences signatures, signature store, signature composer dropdown and refactored tests for signature composer extension. For signature composer extension I removed applyTransformsToDraft and unapplyTransformsToDraft and tested by sending emails with signatures to different providers to make sure the <signature> tag caused problems. Reviewers: bengotow, juan Reviewed By: juan Differential Revision: https://phab.nylas.com/D3073
62 lines
1.9 KiB
JavaScript
62 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 = {
|
|
11: '2',
|
|
22: '2',
|
|
33: 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, 'signatureForAccountId').andCallFake((accountId) => SIGNATURES[DEFAULTS[accountId]])
|
|
spyOn(SignatureStore, 'selectedSignature').andCallFake(() => SIGNATURES['1'])
|
|
SignatureStore.activate()
|
|
})
|
|
|
|
|
|
describe('signatureForAccountId', () => {
|
|
it('should return the default signature for that account', () => {
|
|
const titleForAccount11 = SignatureStore.signatureForAccountId(11).title
|
|
expect(titleForAccount11).toEqual(SIGNATURES['2'].title)
|
|
const account22Def = SignatureStore.signatureForAccountId(33)
|
|
expect(account22Def).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')
|
|
})
|
|
})
|
|
})
|