Skip to content

Commit e5cef77

Browse files
Merge pull request #454 from primeroIMS/trigyn-testcases-pages-admin-form-builder-components-translations-form-components-field-translation-row
Trigyn testcases pages admin form builder components translations form components field translation row
2 parents e2cc126 + 5cdcb7a commit e5cef77

File tree

2 files changed

+48
-55
lines changed

2 files changed

+48
-55
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright (c) 2014 - 2023 UNICEF. All rights reserved.
2+
3+
import { fromJS } from "immutable";
4+
5+
import { mountedFormComponent } from "../../../../../../../../test-utils";
6+
7+
import FieldTranslationRow from "./component";
8+
9+
describe("<FieldTranslationRow />", () => {
10+
const field1 = {
11+
name: "field_1",
12+
display_name: { fr: "Field 1", ar: "Field 1", en: "Field 1" },
13+
type: "text_field"
14+
};
15+
16+
const state = fromJS({
17+
application: { primero: { locales: ["en", "fr", "ar"] } },
18+
records: {
19+
admin: {
20+
forms: {
21+
selectedFields: [
22+
field1,
23+
{
24+
name: "field_2",
25+
display_name: { en: "Field 2" }
26+
}
27+
]
28+
}
29+
}
30+
}
31+
});
32+
33+
const props = { field: fromJS(field1), selectedLocaleId: "fr", formMode: {}, formMethods: {} };
34+
35+
it("should render the <FormSectionField /> for the fr language", () => {
36+
mountedFormComponent(<FieldTranslationRow {...props} />, { state });
37+
expect(document.getElementById("fields.field_1.display_name.en")).toBeInTheDocument();
38+
expect(document.getElementById("fields.field_1.display_name.fr")).toBeInTheDocument();
39+
});
40+
41+
it("should render the <FormSectionField /> for the ar language", () => {
42+
const arProps = { field: fromJS(field1), selectedLocaleId: "ar", formMode: {}, formMethods: {} };
43+
44+
mountedFormComponent(<FieldTranslationRow {...arProps} />, { state });
45+
expect(document.getElementById("fields.field_1.display_name.en")).toBeInTheDocument();
46+
expect(document.getElementById("fields.field_1.display_name.ar")).toBeInTheDocument();
47+
});
48+
});

app/javascript/components/pages/admin/form-builder/components/translations-form/components/field-translation-row/component.unit.test.js

-55
This file was deleted.

0 commit comments

Comments
 (0)