Skip to content
This repository was archived by the owner on Oct 6, 2024. It is now read-only.

Commit a96a1ca

Browse files
committed
Added Snapshot tests of second page of Service Category Admin Page
1 parent 0a0bfc1 commit a96a1ca

File tree

2 files changed

+562
-0
lines changed

2 files changed

+562
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import React from "react";
2+
import renderer from "react-test-renderer";
3+
import svcCatPageOne from "../data/service-categories-page1.mock.json"
4+
import ServiceCategoryTable from "../components/ServiceCategoryTable";
5+
6+
test("snapshots matching", () => {
7+
const component = renderer.create(
8+
<ServiceCategoryTable
9+
serviceCategories={svcCatPageOne.content}
10+
new_entry={{ serviceCategoryName: "", popularity: "", icon: "", id: -1 }} />
11+
);
12+
let tree = component.toJSON();
13+
let root = component.root;
14+
expect(tree).toMatchSnapshot();
15+
expect(root.findAllByType("tr").length).toBe(3 + 2);
16+
})
17+
18+
test("snapshots matching", () => {
19+
var new_entry = { serviceCategoryName: "Hello Hello", popularity: 45, icon: "", id: -1 };
20+
const component = renderer.create(
21+
<ServiceCategoryTable
22+
serviceCategories={svcCatPageOne.content}
23+
new_entry={new_entry} />
24+
);
25+
let tree = component.toJSON();
26+
let root = component.root;
27+
expect(tree).toMatchSnapshot();
28+
expect(root.findAllByType("input")[0].props.value).toBe("Hello Hello");
29+
expect(root.findAllByType("input")[1].props.value).toBe(45);
30+
expect(root.findAllByType("input").length).toBe(2);
31+
})

0 commit comments

Comments
 (0)