-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathcomponent.spec.js
122 lines (110 loc) · 3.06 KB
/
component.spec.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// Copyright (c) 2014 - 2023 UNICEF. All rights reserved.
import { fromJS } from "immutable";
import { mountedComponent, screen } from "test-utils";
import { RECORD_TYPES } from "../../../../config";
import { FieldRecord } from "../../../record-form/records";
import { mapEntriesToRecord } from "../../../../libs";
import IncidentPanel from "./component";
describe("<IncidentPanel /> - Component", () => {
const props = {
incident: fromJS({
created_by: "primero_gbv",
module_id: "primeromodule-gbv",
incident_date: "2020-09-16",
owned_by: "primero_gbv",
date_of_first_report: "2020-10-04",
gbv_sexual_violence_type: "test1",
cp_incident_violence_type: "test1",
unique_id: "e25c5cb1-1257-472e-b2ec-05f568a3b51e"
}),
incidentCaseId: "case-id-1",
css: {},
mode: { isShow: false, isEdit: true },
setFieldValue: () => {},
handleSubmit: () => {},
recordType: RECORD_TYPES.cases
};
const values = [
{
id: "test1",
display_text: {
en: "Test1"
}
},
{
id: "test2",
display_text: {
en: "Test2"
}
}
];
const fields = {
1: {
name: "gbv_sexual_violence_type",
type: "select_field",
option_strings_source: "lookup lookup-gbv-sexual-violence-type",
display_name: { en: "First Name" }
}
};
const initialState = fromJS({
application: {
modules: [
{
unique_id: "primeromodule-cp",
field_map: {
fields: [],
map_to: "primeromodule-cp"
},
name: "CP",
associated_record_types: ["case", "tracing_request", "incident"],
options: {
allow_searchable_ids: true,
use_workflow_case_plan: true,
use_workflow_assessment: false,
reporting_location_filter: true,
use_workflow_service_implemented: true
},
workflows: {}
}
]
},
forms: {
options: {
lookups: [
{
id: 1,
unique_id: "lookup-gbv-sexual-violence-type",
name: {
en: "Gbv Sexual Violence Type"
},
values
},
{
id: 2,
unique_id: "lookup-cp-violence-type",
name: {
en: "CP Sexual Violence Type"
},
values
}
]
},
fields: mapEntriesToRecord(fields, FieldRecord)
}
});
beforeEach(() => {
mountedComponent(<IncidentPanel {...props} />, initialState);
});
it("render IncidentPanel component", () => {
expect(screen.getByTestId("panel")).toBeInTheDocument();
});
it("render IncidentSummary component", () => {
expect(screen.getAllByTestId("incidentsummary")).toHaveLength(1);
});
it("render IncidentDetail component", () => {
expect(screen.getByText("incidents.date_of_incident")).toBeInTheDocument();
});
it("with violence-type-lookup-renders the translated value", () => {
expect(screen.getAllByText("Test1")).toHaveLength(2);
});
});