Skip to content

Commit

Permalink
Added test
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewlipski committed Dec 20, 2024
1 parent 290b2e6 commit be92b7f
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
[
{
"children": [],
"content": [
{
"styles": {},
"text": "ParagraphParagraph",
"type": "text",
},
],
"id": "0",
"props": {
"backgroundColor": "default",
"textAlignment": "left",
"textColor": "default",
},
"type": "paragraph",
},
{
"children": [],
"content": {
"columnWidths": [
undefined,
undefined,
],
"rows": [
{
"cells": [
[
{
"styles": {},
"text": "Table Cell",
"type": "text",
},
],
[
{
"styles": {},
"text": "Table Cell",
"type": "text",
},
],
],
},
{
"cells": [
[
{
"styles": {},
"text": "Table Cell",
"type": "text",
},
],
[
{
"styles": {},
"text": "Table Cell",
"type": "text",
},
],
],
},
],
"type": "tableContent",
},
"id": "1",
"props": {
"textColor": "default",
},
"type": "table",
},
{
"children": [],
"content": [
{
"styles": {},
"text": "Custom Paragraph",
"type": "text",
},
],
"id": "2",
"props": {},
"type": "customParagraph",
},
{
"children": [],
"content": [],
"id": "3",
"props": {
"backgroundColor": "default",
"textAlignment": "left",
"textColor": "default",
},
"type": "paragraph",
},
]
21 changes: 16 additions & 5 deletions packages/core/src/api/clipboard/clipboardExternal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@ import { schema } from "./testUtil.js";
type SelectionTestCase = {
testName: string;
createSelection: (doc: Node) => Selection;
html: string;
};
} & (
| {
html: string;
}
| {
plainText: string;
}
);

// These tests are meant to test the pasting of external HTML in the editor.
// Each test case has an HTML string to be pasted, and a selection in the editor
Expand Down Expand Up @@ -85,9 +91,9 @@ describe("Test external clipboard HTML", () => {

doPaste(
editor.prosemirrorView,
"text",
testCase.html,
false,
"plainText" in testCase ? testCase.plainText : "",
"html" in testCase ? testCase.html : "",
"plainText" in testCase,
new ClipboardEvent("paste")
);

Expand All @@ -102,6 +108,11 @@ describe("Test external clipboard HTML", () => {
createSelection: (doc) => TextSelection.create(doc, 12),
html: `<p>Paragraph</p>`,
},
{
testName: "pasteEndOfParagraphText",
createSelection: (doc) => TextSelection.create(doc, 12),
plainText: `Paragraph`,
},
{
testName: "pasteImage",
createSelection: (doc) => TextSelection.create(doc, 12),
Expand Down

0 comments on commit be92b7f

Please sign in to comment.