Skip to content

Commit 6dfdd21

Browse files
toBeEmpty tests
1 parent 41d0f97 commit 6dfdd21

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { AssertionError, expect } from "@assertive-ts/core";
2+
import { render } from "@testing-library/react-native";
3+
import { View, Text } from "react-native";
4+
5+
import { ToBeEmptyElementAssertion } from "../../src/lib/ToBeEmptyElementAssertion";
6+
7+
describe("[Unit] ToBeEmptyElementAssertion.test.ts", () => {
8+
describe(".toBeEmptyElement", () => {
9+
context("when the element is empty", () => {
10+
it("returns the assertion instance", () => {
11+
const element = render(<View testID="id" />);
12+
const test = new ToBeEmptyElementAssertion(element.getByTestId("id"));
13+
14+
expect(test.toBeEmptyElement()).toBe(test);
15+
expect(() => test.not.toBeEmptyElement())
16+
.toThrowError(AssertionError)
17+
.toHaveMessage("Expected element <View ... /> to NOT be empty.");
18+
});
19+
});
20+
21+
context("when the element is NOT empty", () => {
22+
it("throws an error", () => {
23+
const element = render(
24+
<View testID="id">
25+
<Text>{"Not empty"}</Text>
26+
</View>,
27+
);
28+
const test = new ToBeEmptyElementAssertion(element.getByTestId("id"));
29+
30+
expect(test.not.toBeEmptyElement()).toBeEqual(test);
31+
expect(() => test.toBeEmptyElement())
32+
.toThrowError(AssertionError)
33+
.toHaveMessage("Expected element <View ... /> to be empty.");
34+
});
35+
});
36+
});
37+
});

0 commit comments

Comments
 (0)