Skip to content

Commit e2cc126

Browse files
Merge pull request #453 from primeroIMS/trigyn-testcases-record-form-form-subforms-subform-item
Trigyn testcases record form form subforms subform item
2 parents a994697 + e16435d commit e2cc126

File tree

2 files changed

+129
-166
lines changed

2 files changed

+129
-166
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
import { fromJS } from "immutable";
2+
3+
import { mountedComponent, screen } from "../../../../../test-utils";
4+
import { FieldRecord, FormSectionRecord } from "../../../records";
5+
6+
import SubformItem from "./component";
7+
8+
describe("<SubformItem />", () => {
9+
const props = {
10+
arrayHelpers: {},
11+
dialogIsNew: true,
12+
field: { subform_section_id: { unique_id: "perpetrators", fields: [] } },
13+
formik: {},
14+
forms: {},
15+
formSection: {},
16+
index: 0,
17+
isDisabled: false,
18+
isTraces: false,
19+
isReadWriteForm: false,
20+
isViolation: false,
21+
mode: {},
22+
open: true,
23+
orderedValues: [],
24+
recordModuleID: "primeromodule-cp",
25+
recordType: "cases",
26+
selectedValue: {},
27+
setOpen: () => {},
28+
title: "This is a title"
29+
};
30+
31+
it("should render SubformItem component", () => {
32+
mountedComponent(<SubformItem {...props} />);
33+
expect(screen.getByRole("dialog")).toBeInTheDocument();
34+
});
35+
36+
describe("when is isTraces ", () => {
37+
it("should render SubformTraces component", () => {
38+
mountedComponent(
39+
<SubformItem
40+
{...{
41+
...props,
42+
isTraces: true,
43+
mode: { isShow: true },
44+
formSection: FormSectionRecord({
45+
fields: [],
46+
setIn: () => {}
47+
})
48+
}}
49+
/>
50+
);
51+
52+
expect(screen.getByText("tracing_request.traces")).toBeInTheDocument();
53+
});
54+
});
55+
56+
describe("when is isViolation ", () => {
57+
beforeEach(() => {
58+
mountedComponent(
59+
<SubformItem
60+
{...{
61+
...props,
62+
isViolation: true,
63+
field: FieldRecord({
64+
name: "killing",
65+
subform_section_id: FormSectionRecord({
66+
unique_id: "killing",
67+
fields: [
68+
FieldRecord({
69+
name: "killing_number_of_victims",
70+
visible: true,
71+
type: "text_field"
72+
})
73+
]
74+
})
75+
}),
76+
forms: fromJS({
77+
formSections: {
78+
1: {
79+
id: 1,
80+
name: {
81+
en: "Form Section 1"
82+
},
83+
unique_id: "form_section_1",
84+
module_ids: ["some_module"],
85+
visible: true,
86+
is_nested: false,
87+
parent_form: "cases",
88+
fields: [1, 2, 3]
89+
}
90+
},
91+
fields: {
92+
1: {
93+
id: 1,
94+
name: "field_1",
95+
display_name: {
96+
en: "Field 1"
97+
},
98+
type: "text_field",
99+
required: true,
100+
visible: true
101+
},
102+
2: {
103+
id: 2,
104+
name: "field_2",
105+
display_name: {
106+
en: "Field 2"
107+
},
108+
type: "subform",
109+
visible: true
110+
}
111+
}
112+
}),
113+
violationOptions: [{ id: 1, display_text: "test" }],
114+
isViolationAssociation: true,
115+
parentTitle: "Parent Title"
116+
}}
117+
/>
118+
);
119+
});
120+
121+
it("should render SubformDialog component", () => {
122+
expect(screen.getByTestId("subForm-dialog-form")).toBeInTheDocument();
123+
});
124+
125+
it("should render SubformDrawer component", () => {
126+
expect(screen.getByTestId("drawer")).toBeInTheDocument();
127+
});
128+
});
129+
});

app/javascript/components/record-form/form/subforms/subform-item/component.unit.test.js

-166
This file was deleted.

0 commit comments

Comments
 (0)