|
| 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