-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.test.tsx
35 lines (32 loc) · 892 Bytes
/
index.test.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
*
* Tests for For
*
*/
import React from "react";
import { render } from "@utils/testUtils";
import For from "../index";
describe("<For />", () => {
it("should render and match the snapshot", () => {
const { baseElement } = render(
<For
of={[{ name: "Something" }]}
noParent={false}
ParentComponent={() => <div data-testid="for" />}
renderItem={(item, idx: number) => <div key={idx}>{item.name}</div>}
/>
);
expect(baseElement).toMatchSnapshot();
});
it("should contain 1 For component", () => {
const { getAllByTestId } = render(
<For
of={[{ name: "Something" }]}
noParent={false}
ParentComponent={() => <div data-testid="for" />}
renderItem={(item, idx: number) => <div key={idx}>{item.name}</div>}
/>
);
expect(getAllByTestId("for").length).toBe(1);
});
});