mirror of
https://github.com/penpot/penpot.git
synced 2025-06-28 05:46:59 +02:00
✨ Import text-editor code into the repository
This commit is contained in:
parent
68397edd4d
commit
04a0d867b0
65 changed files with 11112 additions and 7 deletions
33
frontend/text-editor/editor/content/dom/Root.test.js
Normal file
33
frontend/text-editor/editor/content/dom/Root.test.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
import { describe, test, expect } from "vitest";
|
||||
import { createEmptyRoot, createRoot, setRootStyles, TAG, TYPE } from './Root'
|
||||
|
||||
/* @vitest-environment jsdom */
|
||||
describe("Root", () => {
|
||||
test("createRoot should throw when passed invalid children", () => {
|
||||
expect(() => createRoot(["Whatever"])).toThrowError(
|
||||
"Invalid root children"
|
||||
);
|
||||
});
|
||||
|
||||
test("createEmptyRoot should create a new root with an empty paragraph", () => {
|
||||
const emptyRoot = createEmptyRoot();
|
||||
expect(emptyRoot).toBeInstanceOf(HTMLDivElement);
|
||||
expect(emptyRoot.nodeName).toBe(TAG);
|
||||
expect(emptyRoot.dataset.itype).toBe(TYPE);
|
||||
expect(emptyRoot.firstChild).toBeInstanceOf(HTMLDivElement);
|
||||
expect(emptyRoot.firstChild.firstChild).toBeInstanceOf(HTMLSpanElement);
|
||||
expect(emptyRoot.firstChild.firstChild.firstChild).toBeInstanceOf(HTMLBRElement);
|
||||
});
|
||||
|
||||
test("setRootStyles should apply only the styles of root to the root", () => {
|
||||
const emptyRoot = createEmptyRoot();
|
||||
setRootStyles(emptyRoot, {
|
||||
["--vertical-align"]: "top",
|
||||
["font-size"]: "25px"
|
||||
});
|
||||
expect(emptyRoot.style.getPropertyValue("--vertical-align")).toBe("top");
|
||||
// We expect this style to be empty because we don't apply it
|
||||
// to the root.
|
||||
expect(emptyRoot.style.getPropertyValue("font-size")).toBe("");
|
||||
})
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue