Skip to content

Commit

Permalink
Add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed May 30, 2024
1 parent e56872f commit 7fca390
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
30 changes: 30 additions & 0 deletions packages/rich-text/src/test/__snapshots__/to-dom.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,21 @@ exports[`recordToDom should not error with overlapping formats (2) 1`] = `
</body>
`;

exports[`recordToDom should preserve comments 1`] = `
<body>
<span
contenteditable="false"
data-rich-text-comment="comment"
>
<span>
[comment]
</span>
</span>
</body>
`;

exports[`recordToDom should preserve emoji 1`] = `
<body>
🍒
Expand All @@ -289,6 +304,21 @@ exports[`recordToDom should preserve emoji in formatting 1`] = `
</body>
`;

exports[`recordToDom should preserve funky comments 1`] = `
<body>
<span
contenteditable="false"
data-rich-text-comment="/funky"
>
<span>
[/funky]
</span>
</span>
</body>
`;

exports[`recordToDom should preserve non breaking space 1`] = `
<body>
test  test
Expand Down
52 changes: 52 additions & 0 deletions packages/rich-text/src/test/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,58 @@ export const spec = [
text: '\ufffc',
},
},
{
description: 'should preserve comments',
html: '<!--comment-->',
createRange: ( element ) => ( {
startOffset: 0,
startContainer: element,
endOffset: 1,
endContainer: element,
} ),
startPath: [ 0, 0 ],
endPath: [ 2, 0 ],
record: {
start: 0,
end: 1,
formats: [ , ],
replacements: [
{
attributes: {
'data-rich-text-comment': 'comment',
},
type: '#comment',
},
],
text: '\ufffc',
},
},
{
description: 'should preserve funky comments',
html: '<//funky>',
createRange: ( element ) => ( {
startOffset: 0,
startContainer: element,
endOffset: 1,
endContainer: element,
} ),
startPath: [ 0, 0 ],
endPath: [ 2, 0 ],
record: {
start: 0,
end: 1,
formats: [ , ],
replacements: [
{
attributes: {
'data-rich-text-comment': '/funky',
},
type: '#comment',
},
],
text: '\ufffc',
},
},
];

export const specWithRegistration = [
Expand Down

0 comments on commit 7fca390

Please sign in to comment.