Skip to content

Commit f966b94

Browse files
committed
test: add test for nested array value
1 parent 63ae890 commit f966b94

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/__tests__/makeReactNativeField.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ const formikContext = {
1919
user: {
2020
username: "bam-dev",
2121
password: "goodchallenge"
22-
}
22+
},
23+
arrayValue: [{ name: "Name 0" }, { name: "Name 1" }]
2324
}
2425
};
2526
const Input = compose(
@@ -44,6 +45,13 @@ describe("makeReactNativeField", () => {
4445
expect(otherInput.find(TextInput).props().value).toEqual(undefined);
4546
});
4647

48+
it("sets the input value for nested array", () => {
49+
const emailInput = mount(<Input name="arrayValue.1.name" />);
50+
expect(emailInput.find(TextInput).props().value).toEqual("Name 1");
51+
const otherInput = mount(<Input name="arrayValue.2.name" />);
52+
expect(otherInput.find(TextInput).props().value).toEqual(undefined);
53+
});
54+
4755
it("handles input value change", () => {
4856
const wrapper = mount(<Input name="email" />);
4957
wrapper

0 commit comments

Comments
 (0)