1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-02-13 03:35:01 +01:00
Renaud Chaput 3339d088e1 Add Prettier with ESLint integration (#1589)
* Add Prettier, with basic config and ESLint integration

* Apply Prettier to all files using `yarn lint --fix`

* Tell Prettier to ignore an empty text in a test output.

* Run Prettier on JS files not handled by ESLint, and lint them too
2018-02-06 15:12:00 -08:00

42 lines
1.1 KiB
JavaScript

import React from 'react'
import ReactDOM from 'react-dom/server'
import assert from 'assert'
import clean from '../helpers/clean'
import fs from 'fs-promise' // eslint-disable-line import/no-extraneous-dependencies
import { JSDOM } from 'jsdom' // eslint-disable-line import/no-extraneous-dependencies
import { Editor } from '../..'
import { basename, extname, resolve } from 'path'
/**
* Tests.
*/
describe('rendering', () => {
const dir = resolve(__dirname, './fixtures')
const tests = fs
.readdirSync(dir)
.filter(t => t[0] != '.' && !!~t.indexOf('.js'))
.map(t => basename(t, extname(t)))
for (const test of tests) {
it(test, async () => {
const module = require(resolve(dir, test))
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)
})
}
})