Skip to content

Commit 4a56982

Browse files
committed
[New] added test cases for record actions add incident fields
1 parent d4ad0ba commit 4a56982

File tree

2 files changed

+72
-1
lines changed

2 files changed

+72
-1
lines changed

app/javascript/components/record-actions/add-incident/fields/component.jsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ const Component = ({ recordModuleID, recordType, fields, formik }) => {
4545
}
4646
};
4747

48-
return <FormSectionField key={`${formattedField.name}-incident`} {...fieldProps} />;
48+
return (
49+
<FormSectionField data-testid="form-section-field" key={`${formattedField.name}-incident`} {...fieldProps} />
50+
);
4951
});
5052

5153
return <>{renderFields}</>;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import { fromJS } from "immutable";
2+
3+
import { mountedComponent, screen } from "../../../../test-utils";
4+
import { RECORD_PATH } from "../../../../config";
5+
6+
import Fields from "./component";
7+
8+
describe("<Fields />", () => {
9+
const props = {
10+
recordType: RECORD_PATH.cases,
11+
fields: [
12+
{
13+
name: "name",
14+
type: "text_field",
15+
editable: true,
16+
disabled: false,
17+
visible: true,
18+
subform_section_id: null,
19+
help_text: {},
20+
multi_select: false,
21+
option_strings_source: null,
22+
option_strings_text: {},
23+
guiding_questions: "",
24+
required: false,
25+
date_validation: "default_date_validation",
26+
hide_on_view_page: false,
27+
date_include_time: false,
28+
selected_value: "",
29+
subform_sort_by: "",
30+
show_on_minify_form: false
31+
}
32+
]
33+
};
34+
35+
const initialState = fromJS({
36+
records: {
37+
cases: {
38+
data: [
39+
{
40+
sex: "male",
41+
created_at: "2020-01-07T14:27:04.136Z",
42+
name: "G P",
43+
case_id_display: "96f613f",
44+
owned_by: "primero_cp",
45+
status: "open",
46+
registration_date: "2020-01-07",
47+
id: "d9df44fb-95d0-4407-91fd-ed18c19be1ad"
48+
}
49+
]
50+
}
51+
}
52+
});
53+
54+
const formProps = {
55+
initialValues: {
56+
name: ""
57+
}
58+
};
59+
60+
it("renders 1 FormSectionField", () => {
61+
mountedComponent(<Fields {...props} />, initialState, {}, {}, formProps);
62+
expect(screen.getByRole("textbox")).toBeInTheDocument();
63+
});
64+
65+
it("renders component with valid props", () => {
66+
mountedComponent(<Fields {...props} />, initialState, {}, {}, formProps);
67+
expect(screen.getByRole("textbox")).toBeInTheDocument();
68+
});
69+
});

0 commit comments

Comments
 (0)