Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TrangPham committed Mar 19, 2024
1 parent 1d9c25a commit 3ce20bb
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/controls/ObjectArrayControl.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ test.each([
},
)

// test with paramaterized schema
test.each([
[objectArrayControlJsonSchema],
[objectArrayControlJsonSchemaWithRequired],
Expand All @@ -61,7 +60,7 @@ test.each([
)

test("ObjectArrayControl correctly appends to the list with add button", async () => {
let data = { assets: [{ asset: "my asset" }] }
let data = { assets: [] }
const user = userEvent.setup()
render({
schema: objectArrayControlJsonSchema,
Expand All @@ -71,14 +70,13 @@ test("ObjectArrayControl correctly appends to the list with add button", async (
data = result.data
},
})
await screen.findByDisplayValue("my asset")
await user.click(screen.getByRole("button", { name: "Add Assets" }))
const newAsset = await screen.findByDisplayValue("")
const newAsset = await screen.findByLabelText("Asset")
await user.type(newAsset, "new")
await screen.findByDisplayValue("new")
await waitFor(() => {
expect(data).toEqual({
assets: [{ asset: "my asset" }, { asset: "new" }],
assets: [{ asset: "new" }],
})
})
})
Expand Down

0 comments on commit 3ce20bb

Please sign in to comment.