Skip to content

Commit 31a3a12

Browse files
committed
chore: add more test on rich text
1 parent 376e496 commit 31a3a12

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed
20 KB
Loading

packages/pluggableWidgets/rich-text-web/src/__tests__/RichText.spec.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import { createElement } from "react";
55
import { RichTextContainerProps } from "../../typings/RichTextProps";
66

77
import RichText from "../RichText";
8-
8+
const richTextDefaultValue = `<h2><strong>Rich text default value</strong></h2>`;
99
describe("Rich Text", () => {
1010
let defaultProps: RichTextContainerProps;
1111
beforeEach(() => {
1212
defaultProps = {
1313
name: "RichText",
1414
id: "RichText1",
15-
stringAttribute: new EditableValueBuilder<string>().withValue("Rich text default value").build(),
15+
stringAttribute: new EditableValueBuilder<string>().withValue(richTextDefaultValue).build(),
1616
preset: "basic",
1717
toolbarLocation: "bottom",
1818
widthUnit: "percentage",
@@ -59,4 +59,19 @@ describe("Rich Text", () => {
5959
const component = render(<RichText {...defaultProps} toolbarLocation={"top"} preset={"full"} />);
6060
expect(component.container).toMatchSnapshot();
6161
});
62+
63+
it("renders richtext widget with readonly config", async () => {
64+
const component = render(
65+
<RichText
66+
{...defaultProps}
67+
readOnlyStyle={"bordered"}
68+
stringAttribute={new EditableValueBuilder<string>()
69+
.withValue(richTextDefaultValue)
70+
.isReadOnly()
71+
.build()}
72+
/>
73+
);
74+
75+
expect(component.container).toMatchSnapshot();
76+
});
6277
});

packages/pluggableWidgets/rich-text-web/src/__tests__/__snapshots__/RichText.spec.tsx.snap

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,3 +690,24 @@ exports[`Rich Text renders richtext widget with different config 1`] = `
690690
</div>
691691
</div>
692692
`;
693+
694+
exports[`Rich Text renders richtext widget with readonly config 1`] = `
695+
<div>
696+
<div
697+
class="widget-rich-text form-control widget-rich-text-readonly-bordered flex-column editor-bordered"
698+
spellcheck="true"
699+
style="width: 100%;"
700+
tabindex="0"
701+
>
702+
<div
703+
class="flexcontainer flex-column-reverse hide-toolbar"
704+
>
705+
<div
706+
class="widget-rich-text-container"
707+
style="height: auto;"
708+
/>
709+
<div />
710+
</div>
711+
</div>
712+
</div>
713+
`;

0 commit comments

Comments
 (0)