Skip to content

Commit

Permalink
test: add visibility tests #484
Browse files Browse the repository at this point in the history
  • Loading branch information
mturoci committed Jul 28, 2021
1 parent 7c5654b commit a9d6bd9
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions ui/src/form.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import { render } from '@testing-library/react'
import * as T from 'h2o-wave'
import React from 'react'
import { Button, Buttons } from './button'
import { View } from './form'

const
Expand All @@ -31,4 +32,28 @@ describe('Form.tsx', () => {
const { queryByTestId } = render(<View {...formProps} />)
expect(queryByTestId(name)).toBeInTheDocument()
})

it('Hides a button component', () => {
const
button: Button = { name: 'btn', visible: false },
_formProps = { ...formProps, state: { items: [{ button }] } },
{ queryByTestId } = render(<View {..._formProps} />)
expect(queryByTestId('btn')).not.toBeVisible()
})

it('Hides a button component within buttons', () => {
const
buttons: Buttons = { items: [{ button: { name: 'btn', visible: false } }] },
_formProps = { ...formProps, state: { items: [{ buttons }] } },
{ queryByTestId } = render(<View {..._formProps} />)
expect(queryByTestId('btn')).not.toBeVisible()
})

it('Hides a button component within inline', () => {
const
inline = { items: [{ button: { name: 'btn', visible: false } }] },
_formProps = { ...formProps, state: { items: [{ inline }] } },
{ queryByTestId } = render(<View {..._formProps} />)
expect(queryByTestId('btn')).not.toBeVisible()
})
})

0 comments on commit a9d6bd9

Please sign in to comment.