Skip to content

Commit

Permalink
chore: add browser test
Browse files Browse the repository at this point in the history
  • Loading branch information
yuwu9145 committed Jan 18, 2025
1 parent 9d77253 commit e11dbe2
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -672,4 +672,37 @@ describe.each([
expect(el).toBeVisible()
})
})

// https://github.com/vuetifyjs/vuetify/issues/20830
it('should return correct isOpen state in prepend slot', async () => {
render(() => (
<VTreeview
items={ items }
item-value="id"
open-on-click
return-object
>
{{
prepend: ({ isOpen }) => (<span class="prepend-is-open">{ `${isOpen}` }</span>),
}}
</VTreeview>
))

await userEvent.click(screen.getByText(/Vuetify Human Resources/))
const itemsPrepend = screen.getAllByCSS('.v-treeview-item .v-list-item__prepend .prepend-is-open')
expect(itemsPrepend[0]).toHaveTextContent(/^true$/)
expect(itemsPrepend[1]).toHaveTextContent(/^false$/)

await userEvent.click(screen.getByText(/Core team/))
expect(itemsPrepend[0]).toHaveTextContent(/^true$/)
expect(itemsPrepend[1]).toHaveTextContent(/^true$/)

await userEvent.click(screen.getByText(/Core team/))
expect(itemsPrepend[0]).toHaveTextContent(/^true$/)
expect(itemsPrepend[1]).toHaveTextContent(/^false$/)

await userEvent.click(screen.getByText(/Vuetify Human Resources/))
expect(itemsPrepend[0]).toHaveTextContent(/^false$/)
expect(itemsPrepend[1]).toHaveTextContent(/^false$/)
})
})

0 comments on commit e11dbe2

Please sign in to comment.