mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-12 12:40:08 +08:00
6315bc9d80
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
33 lines
1.3 KiB
CoffeeScript
33 lines
1.3 KiB
CoffeeScript
SpellcheckComposerExtension = require '../lib/spellcheck-composer-extension'
|
|
fs = require 'fs'
|
|
_ = require 'underscore'
|
|
|
|
initialHTML = fs.readFileSync(__dirname + '/fixtures/california-with-misspellings-before.html').toString()
|
|
expectedHTML = fs.readFileSync(__dirname + '/fixtures/california-with-misspellings-after.html').toString()
|
|
|
|
describe "SpellcheckComposerExtension", ->
|
|
beforeEach ->
|
|
# Avoid differences between node-spellcheck on different platforms
|
|
spellings = JSON.parse(fs.readFileSync(__dirname + '/fixtures/california-spelling-lookup.json'))
|
|
spyOn(SpellcheckComposerExtension, 'isMisspelled').andCallFake (word) ->
|
|
spellings[word]
|
|
|
|
describe "walkTree", ->
|
|
it "correctly walks a DOM tree and surrounds mispelled words", ->
|
|
dom = document.createElement('div')
|
|
dom.innerHTML = initialHTML
|
|
SpellcheckComposerExtension.walkTree(dom)
|
|
expect(dom.innerHTML).toEqual(expectedHTML)
|
|
|
|
describe "finalizeSessionBeforeSending", ->
|
|
it "removes the annotations it inserted", ->
|
|
session =
|
|
draft: ->
|
|
body: expectedHTML
|
|
changes:
|
|
add: jasmine.createSpy('add')
|
|
|
|
SpellcheckComposerExtension.finalizeSessionBeforeSending({session})
|
|
expect(session.changes.add).toHaveBeenCalledWith(body: initialHTML)
|
|
|
|
module.exports = SpellcheckComposerExtension
|