|
| 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 | +}); |
0 commit comments