-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of bitbucket.org:quoin/primero into r2-1941_2.2…
….0.2-to-master
- Loading branch information
Showing
171 changed files
with
4,610 additions
and
310 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
app/javascript/components/record-form/components/render-form-sections.unit.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { fromJS } from "immutable"; | ||
|
||
import { setupMountedComponent } from "../../../test"; | ||
import { FormSectionRecord, FieldRecord } from "../records"; | ||
import TextField from "../form/field-types/text-field"; | ||
import { TEXT_FIELD } from "../constants"; | ||
|
||
import renderFormSections from "./render-form-sections"; | ||
|
||
describe("renderFormSections()", () => { | ||
it("does not render the fields that do not meet the conditions", () => { | ||
const externalForms = () => {}; | ||
const selectedForm = "form1"; | ||
const userPermittedFormsIds = fromJS({ selectedForm: "rw" }); | ||
const mobileDisplay = false; | ||
const handleToggleNav = () => {}; | ||
const i18n = () => {}; | ||
const recordType = "recordType1"; | ||
const attachmentForms = []; | ||
const mode = { isEdit: true }; | ||
const record = fromJS({}); | ||
const primeroModule = "primeroModule1"; | ||
|
||
const formSectionsRender = renderFormSections( | ||
externalForms, | ||
selectedForm, | ||
userPermittedFormsIds, | ||
mobileDisplay, | ||
handleToggleNav, | ||
i18n, | ||
recordType, | ||
attachmentForms, | ||
mode, | ||
record, | ||
primeroModule | ||
); | ||
|
||
const formSection = () => | ||
formSectionsRender( | ||
[ | ||
FormSectionRecord({ | ||
unique_id: "form1", | ||
visible: true, | ||
fields: [ | ||
FieldRecord({ | ||
name: "field1", | ||
type: TEXT_FIELD, | ||
visible: true, | ||
display_conditions_record: { eq: { sex: "male" } } | ||
}), | ||
FieldRecord({ | ||
name: "field2", | ||
type: TEXT_FIELD, | ||
visible: true, | ||
display_conditions_record: { le: { age: 18 } } | ||
}), | ||
FieldRecord({ name: "field3", type: TEXT_FIELD, visible: true }) | ||
] | ||
}) | ||
], | ||
() => {}, | ||
() => {}, | ||
{ sex: "male", age: 19 }, | ||
false | ||
); | ||
|
||
const renderedFormSections = () => <>{formSection()}</>; | ||
|
||
const { component } = setupMountedComponent(renderedFormSections, {}, {}, [], { initialValues: {} }); | ||
|
||
expect(component.find(TextField)).to.have.lengthOf(2); | ||
}); | ||
}); |
Oops, something went wrong.