UNPKG

slate-test-utils

Version:

> 📣 Love Slate and looking for your next gig? Sirona Medical is [hiring](https://sironamedical.com/about-us/careers/)!

15 lines (14 loc) • 534 B
// Ensures that the hyperscript you create follows the rules of Slate import cloneDeep from 'lodash.clonedeep'; import { Editor } from 'slate'; /** * Ensures the Slate content you create is valid. Useful * for unit testing to make sure you are adhering to the * rules of Slate. */ export const ensureSlateStateValid = (editor) => { const cloned = cloneDeep(editor); Editor.normalize(editor, { force: true }); expect(editor.children).toEqual(cloned.children); expect(editor.selection).toEqual(cloned.selection); };