|
1 | 1 | // Copyright (c) 2014 - 2023 UNICEF. All rights reserved.
|
2 | 2 |
|
3 | 3 | import { fromJS } from "immutable";
|
4 |
| -import { Accordion, AccordionDetails, AccordionSummary } from "@material-ui/core"; |
| 4 | +import { mountedComponent, screen } from "test-utils"; |
5 | 5 |
|
6 |
| -import LookupValue from "../../../record-form/form/subforms/subform-header-lookup"; |
7 |
| -import { setupMountedComponent } from "../../../../test"; |
8 |
| -import IncidentSummary from "../summary"; |
9 |
| -import IncidentDetail from "../detail"; |
10 | 6 | import { RECORD_TYPES } from "../../../../config";
|
11 |
| -import * as R from "../../../record-form/records"; |
| 7 | +import { FieldRecord } from "../../../record-form/records"; |
12 | 8 | import { mapEntriesToRecord } from "../../../../libs";
|
13 | 9 |
|
14 | 10 | import IncidentPanel from "./component";
|
15 | 11 |
|
16 | 12 | describe("<IncidentPanel /> - Component", () => {
|
17 |
| - let component; |
18 | 13 | const props = {
|
19 | 14 | incident: fromJS({
|
20 | 15 | created_by: "primero_gbv",
|
@@ -101,51 +96,27 @@ describe("<IncidentPanel /> - Component", () => {
|
101 | 96 | }
|
102 | 97 | ]
|
103 | 98 | },
|
104 |
| - fields: mapEntriesToRecord(fields, R.FieldRecord) |
| 99 | + fields: mapEntriesToRecord(fields, FieldRecord) |
105 | 100 | }
|
106 | 101 | });
|
107 | 102 |
|
108 | 103 | beforeEach(() => {
|
109 |
| - ({ component } = setupMountedComponent(IncidentPanel, props, initialState)); |
| 104 | + mountedComponent(<IncidentPanel {...props} />, initialState); |
110 | 105 | });
|
111 | 106 |
|
112 | 107 | it("render IncidentPanel component", () => {
|
113 |
| - expect(component.find(IncidentPanel)).to.have.length(1); |
| 108 | + expect(screen.getByTestId("panel")).toBeInTheDocument(); |
114 | 109 | });
|
115 | 110 |
|
116 |
| - it("render a Accordions", () => { |
117 |
| - expect(component.find(Accordion)).to.have.lengthOf(1); |
118 |
| - expect(component.find(AccordionSummary)).to.have.lengthOf(1); |
119 |
| - expect(component.find(AccordionDetails)).to.have.lengthOf(1); |
| 111 | + it("render IncidentSummary component", () => { |
| 112 | + expect(screen.getAllByTestId("incidentsummary")).toHaveLength(1); |
120 | 113 | });
|
121 | 114 |
|
122 |
| - it("render a IncidentSummary", () => { |
123 |
| - expect(component.find(IncidentSummary)).to.have.lengthOf(1); |
| 115 | + it("render IncidentDetail component", () => { |
| 116 | + expect(screen.getByText("incidents.date_of_incident")).toBeInTheDocument(); |
124 | 117 | });
|
125 | 118 |
|
126 |
| - it("render a IncidentDetail", () => { |
127 |
| - expect(component.find(IncidentDetail)).to.have.lengthOf(1); |
128 |
| - }); |
129 |
| - |
130 |
| - describe("with violence-type-lookup", () => { |
131 |
| - it("should use the lookup defined in the option_strings_source", () => { |
132 |
| - expect(component.find(IncidentDetail).find(LookupValue).props().optionsStringSource).to.equal( |
133 |
| - "lookup-gbv-sexual-violence-type" |
134 |
| - ); |
135 |
| - }); |
136 |
| - |
137 |
| - it("renders the translated value", () => { |
138 |
| - expect(component.find(IncidentDetail).find(LookupValue).text()).to.equal("Test1"); |
139 |
| - }); |
140 |
| - }); |
141 |
| - |
142 |
| - it("renders component with valid props", () => { |
143 |
| - const incidentsProps = { ...component.find(IncidentPanel).props() }; |
144 |
| - |
145 |
| - ["incident", "incidentCaseId", "css", "mode", "setFieldValue", "handleSubmit", "recordType"].forEach(property => { |
146 |
| - expect(incidentsProps).to.have.property(property); |
147 |
| - delete incidentsProps[property]; |
148 |
| - }); |
149 |
| - expect(incidentsProps).to.be.empty; |
| 119 | + it("with violence-type-lookup-renders the translated value", () => { |
| 120 | + expect(screen.getAllByText("Test1")).toHaveLength(2); |
150 | 121 | });
|
151 | 122 | });
|
0 commit comments