2018-08-01 09:16:02 -07:00
|
|
|
import assert from 'assert'
|
|
|
|
import clean from './helpers/clean'
|
|
|
|
import React from 'react'
|
|
|
|
import ReactDOM from 'react-dom/server'
|
2018-08-06 13:31:42 -04:00
|
|
|
import { Editor } from 'slate-react'
|
2018-08-01 09:16:02 -07:00
|
|
|
import { fixtures } from 'slate-dev-test-utils'
|
|
|
|
import { JSDOM } from 'jsdom'
|
2017-09-11 18:11:45 -07:00
|
|
|
|
|
|
|
describe('slate-react', () => {
|
2018-08-01 09:16:02 -07:00
|
|
|
fixtures(__dirname, 'rendering/fixtures', ({ module }) => {
|
|
|
|
const { value, output, props } = module
|
|
|
|
const p = {
|
|
|
|
value,
|
|
|
|
onChange() {},
|
|
|
|
...(props || {}),
|
|
|
|
}
|
|
|
|
|
|
|
|
const string = ReactDOM.renderToStaticMarkup(<Editor {...p} />)
|
|
|
|
const dom = JSDOM.fragment(output)
|
|
|
|
const expected = dom.firstChild.outerHTML
|
|
|
|
.trim()
|
|
|
|
.replace(/\n/gm, '')
|
|
|
|
.replace(/>\s*</g, '><')
|
|
|
|
|
|
|
|
assert.equal(clean(string), expected)
|
|
|
|
})
|
2017-09-11 18:11:45 -07:00
|
|
|
})
|