slate-test-utils
Version:
> 📣 Love Slate and looking for your next gig? Sirona Medical is [hiring](https://sironamedical.com/about-us/careers/)!
19 lines (18 loc) • 745 B
JavaScript
;
// Ensures that the hyperscript you create follows the rules of Slate
Object.defineProperty(exports, "__esModule", { value: true });
exports.ensureSlateStateValid = void 0;
const lodash_clonedeep_1 = require("lodash.clonedeep");
const slate_1 = require("slate");
/**
* Ensures the Slate content you create is valid. Useful
* for unit testing to make sure you are adhering to the
* rules of Slate.
*/
const ensureSlateStateValid = (editor) => {
const cloned = (0, lodash_clonedeep_1.default)(editor);
slate_1.Editor.normalize(editor, { force: true });
expect(editor.children).toEqual(cloned.children);
expect(editor.selection).toEqual(cloned.selection);
};
exports.ensureSlateStateValid = ensureSlateStateValid;