Mailspring/internal_packages/message-list/spec/autolinker-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

28 lines
1.1 KiB
CoffeeScript

Autolinker = require 'autolinker'
AutolinkerExtension = require '../lib/plugins/autolinker-extension'
describe "AutolinkerExtension", ->
beforeEach ->
spyOn(Autolinker, 'link').andCallFake (txt) => txt
it "should call through to Autolinker", ->
AutolinkerExtension.formatMessageBody(message: {body:'body'})
expect(Autolinker.link).toHaveBeenCalledWith('body', {twitter: false})
it "should add a title to everything with an href", ->
message =
body: """
<a href="apple.com">hello world!</a>
<a href = "http://apple.com">hello world!</a>
<a href ='http://apple.com'>hello world!</a>
<a href ='mailto://'>hello world!</a>
"""
expected =
body: """
<a href="apple.com" title="apple.com" >hello world!</a>
<a href = "http://apple.com" title="http://apple.com" >hello world!</a>
<a href ='http://apple.com' title='http://apple.com' >hello world!</a>
<a href ='mailto://' title='mailto://' >hello world!</a>
"""
AutolinkerExtension.formatMessageBody({message})
expect(message.body).toEqual(expected.body)