|
1 | 1 | // Copyright (c) 2014 - 2023 UNICEF. All rights reserved.
|
2 |
| - |
3 |
| -import { Formik, Form } from "formik"; |
4 | 2 | import { fromJS, Map, OrderedMap } from "immutable";
|
5 | 3 |
|
6 |
| -import ActionDialog from "../../action-dialog"; |
7 |
| -import { setupMountedComponent } from "../../../test"; |
| 4 | +import { mountedComponent, screen } from "../../../test-utils"; |
8 | 5 | import { FieldRecord, FormSectionRecord } from "../../record-form/records";
|
9 | 6 | import { RECORD_PATH } from "../../../config";
|
10 |
| -import Fields from "../add-incident/fields"; |
11 | 7 |
|
12 | 8 | import AddService from "./component";
|
13 | 9 |
|
14 | 10 | describe("<AddService />", () => {
|
15 |
| - let component; |
16 | 11 | const initialState = Map({
|
17 | 12 | records: fromJS({
|
18 | 13 | cases: {
|
@@ -124,33 +119,23 @@ describe("<AddService />", () => {
|
124 | 119 | setPending: () => {}
|
125 | 120 | };
|
126 | 121 |
|
127 |
| - beforeEach(() => { |
128 |
| - ({ component } = setupMountedComponent(AddService, props, initialState)); |
129 |
| - }); |
130 |
| - |
131 | 122 | it("renders Formik", () => {
|
132 |
| - expect(component.find(Formik)).to.have.lengthOf(1); |
| 123 | + mountedComponent(<AddService {...props} />, initialState); |
| 124 | + expect(screen.getByText((content, element) => element.tagName.toLowerCase() === "form")).toBeInTheDocument(); |
133 | 125 | });
|
134 | 126 |
|
135 | 127 | it("renders ActionDialog", () => {
|
136 |
| - expect(component.find(ActionDialog)).to.have.lengthOf(1); |
| 128 | + mountedComponent(<AddService {...props} />, initialState); |
| 129 | + expect(screen.getByRole("dialog")).toBeInTheDocument(); |
137 | 130 | });
|
138 | 131 |
|
139 | 132 | it("renders Form", () => {
|
140 |
| - expect(component.find(Form)).to.have.lengthOf(1); |
| 133 | + mountedComponent(<AddService {...props} />, initialState); |
| 134 | + expect(screen.getByText((content, element) => element.tagName.toLowerCase() === "form")).toBeInTheDocument(); |
141 | 135 | });
|
142 | 136 |
|
143 | 137 | it("renders Fields", () => {
|
144 |
| - expect(component.find(Fields)).to.have.lengthOf(1); |
145 |
| - }); |
146 |
| - |
147 |
| - it("renders component with valid props", () => { |
148 |
| - const addService = { ...component.find(AddService).props() }; |
149 |
| - |
150 |
| - ["close", "pending", "recordType", "selectedRowsIndex", "setPending", "open"].forEach(property => { |
151 |
| - expect(addService).to.have.property(property); |
152 |
| - delete addService[property]; |
153 |
| - }); |
154 |
| - expect(addService).to.be.empty; |
| 138 | + mountedComponent(<AddService {...props} />, initialState); |
| 139 | + expect(screen.queryAllByRole("textbox")).toHaveLength(1); |
155 | 140 | });
|
156 | 141 | });
|
0 commit comments