mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-14 13:44:41 +08:00
502bb7c0b8
Summary: New draft store extension that highlights misspelled words. Test Plan: No test coverage yet Reviewers: evan, dillon Reviewed By: evan Differential Revision: https://phab.nylas.com/D1972
33 lines
1.3 KiB
CoffeeScript
33 lines
1.3 KiB
CoffeeScript
SpellcheckDraftStoreExtension = require '../lib/draft-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 "SpellcheckDraftStoreExtension", ->
|
|
beforeEach ->
|
|
# Avoid differences between node-spellcheck on different platforms
|
|
spellings = JSON.parse(fs.readFileSync(__dirname + '/fixtures/california-spelling-lookup.json'))
|
|
spyOn(SpellcheckDraftStoreExtension, 'isMisspelled').andCallFake (word) ->
|
|
spellings[word]
|
|
|
|
describe "walkTree", ->
|
|
it "correctly walks a DOM tree and surrounds mispelled words", ->
|
|
dom = document.createElement('div')
|
|
dom.innerHTML = initialHTML
|
|
SpellcheckDraftStoreExtension.walkTree(dom)
|
|
expect(dom.innerHTML).toEqual(expectedHTML)
|
|
|
|
describe "finalizeSessionBeforeSending", ->
|
|
it "removes the annotations it inserted", ->
|
|
session =
|
|
draft: ->
|
|
body: expectedHTML
|
|
changes:
|
|
add: jasmine.createSpy('add')
|
|
|
|
SpellcheckDraftStoreExtension.finalizeSessionBeforeSending(session)
|
|
expect(session.changes.add).toHaveBeenCalledWith(body: initialHTML)
|
|
|
|
module.exports = SpellcheckDraftStoreExtension
|