Mailspring/internal_packages/composer-signature/spec/signature-composer-extension-spec.coffee
Juan Tejada cd1ee3f672 fix(extension-adapter): Update adapter to support all versions of extension api we've used
Summary:
- Rewrites composer extension adpater to support all versions of the
  ComposerExtension API we've ever declared. This will allow old plugins (or
  plugins that haven't been reinstalled after update) to keep functioning
  without breaking N1
- Adds specs

Test Plan: - Unit tests

Reviewers: evan, bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2399
2015-12-30 15:11:37 -05:00

37 lines
1.6 KiB
CoffeeScript

{Message} = require 'nylas-exports'
SignatureComposerExtension = require '../lib/signature-composer-extension'
describe "SignatureComposerExtension", ->
describe "prepareNewDraft", ->
describe "when a signature is defined", ->
beforeEach ->
@signature = '<div id="signature">This is my signature.</div>'
spyOn(NylasEnv.config, 'get').andCallFake =>
@signature
it "should insert the signature at the end of the message or before the first blockquote and have a newline", ->
a = new Message
draft: true
body: 'This is a test! <blockquote>Hello world</blockquote>'
b = new Message
draft: true
body: 'This is a another test.'
SignatureComposerExtension.prepareNewDraft(draft: a)
expect(a.body).toEqual('This is a test! <br/><div class="nylas-n1-signature"><div id="signature">This is my signature.</div></div><blockquote>Hello world</blockquote>')
SignatureComposerExtension.prepareNewDraft(draft: b)
expect(b.body).toEqual('This is a another test.<br/><div class="nylas-n1-signature"><div id="signature">This is my signature.</div></div>')
describe "when a signature is not defined", ->
beforeEach ->
spyOn(NylasEnv.config, 'get').andCallFake ->
null
it "should not do anything", ->
a = new Message
draft: true
body: 'This is a test! <blockquote>Hello world</blockquote>'
SignatureComposerExtension.prepareNewDraft(draft: a)
expect(a.body).toEqual('This is a test! <blockquote>Hello world</blockquote>')