-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMenuList.test.js
51 lines (47 loc) · 1.32 KB
/
MenuList.test.js
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import React from "react";
import { render, screen } from "@testing-library/react";
import MenuList from "../MenuList";
describe("table", () => {
let itemData = [
{
active: true,
categoryname: "Early Breakfast",
description: "6.30am to 12pm",
id: 1,
itemname: "Idli",
price: 50,
},
{
active: true,
categoryname: "Breakfast",
description: "7.30am to 6.30pm",
id: 6,
itemname: "Parota",
price: 60,
},
];
it("should render item name input", () => {
render(<MenuList itemData={itemData} />);
const trElements = screen.getAllByRole("row");
expect(trElements).toHaveLength(3);
});
it("renders with expected values", () => {
render(<MenuList itemData={itemData} />);
expect(
screen.getByRole("cell", { name: /Early Breakfast/i })
).toBeInTheDocument();
expect(
screen.getByRole("cell", { name: /6.30am to 12pm/i })
).toBeInTheDocument();
expect(screen.getByRole("cell", { name: /Idli/i })).toBeInTheDocument();
expect(screen.getByRole("cell", { name: /50/i })).toBeInTheDocument();
});
it("has the correct class", () => {
render(<MenuList itemData={itemData} />);
// screen.debug();
expect(screen.getByRole("table")).toHaveAttribute(
"class",
"chakra-table css-0"
);
});
});