Skip to content

Commit 48f7144

Browse files
committed
test: add test cases to AbstractRenderer test suite
1 parent ca377dc commit 48f7144

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

src/components/AbstractRenderer/AbrstractRenderer.spec.tsx

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,40 @@ describe("AbstractRenderer component", () => {
2727
expect(e).toHaveTextContent("TEST");
2828
});
2929

30-
it("should render a spanned text", () => {
30+
it("should render an empty string when value is null", () => {
31+
const r = render(<AbstractRendererWrapper value={null} pure />);
32+
expect(r.container.innerHTML).toEqual("");
33+
});
34+
35+
it("should render an empty string when value is undefined", () => {
36+
const r = render(<AbstractRendererWrapper value={undefined} pure />);
37+
expect(r.container.innerHTML).toEqual("");
38+
});
39+
40+
it("should render a spanned empty string when value is null", () => {
41+
const r = render(<AbstractRendererWrapper value={null} />);
42+
expect(r.container.innerHTML).toEqual("<span></span>");
43+
});
44+
45+
it("should render a spanned string when value is undefined", () => {
46+
const r = render(<AbstractRendererWrapper value={undefined} />);
47+
expect(r.container.innerHTML).toEqual("<span></span>");
48+
});
49+
50+
it("should render a spanned text when the 'pure' attribute is ommited", () => {
3151
render(<AbstractRendererWrapper value="TEST" />);
3252
const e = screen.getByText("TEST");
3353
expect(e).toBeInTheDocument();
3454
expect(e.tagName).toEqual("SPAN");
3555
expect(e).toHaveTextContent("TEST");
3656
});
3757

58+
it("should render a spanned text when the 'pure' attribute is null", () => {
59+
render(<AbstractRendererWrapper value="TEST" pure={null} />);
60+
const e = screen.getByText("TEST");
61+
expect(e).toBeInTheDocument();
62+
expect(e.tagName).toEqual("SPAN");
63+
expect(e).toHaveTextContent("TEST");
64+
});
65+
3866
});

0 commit comments

Comments
 (0)