Repository: h2oai/wave
File: ui/src/tall_info.test.tsx (TypeScript)

Code before:
  })

  it('Does not submit data to server if name specified but starts with #', () => {
    tallInfoProps.state.name = `#${name}`
    const { getByTestId } = render(<View {...tallInfoProps} />)
    fireEvent.click(getByTestId(name))
    expect(pushMock).not.toHaveBeenCalled()
    expect(wave.args[name]).toBeUndefined()
  })

  it('Submits data to server if name specified without #', () => {
    tallInfoProps.state.name = name
    const { getByTestId } = render(<View {...tallInfoProps} />)
    fireEvent.click(getByTestId(name))
    expect(pushMock).toHaveBeenCalled()
    expect(wave.args[name]).toBe(name)
  })

  it('Makes card clickable only if name was specified but label was not', () => {
    const { getByTestId } = render(<View {...tallInfoProps} />)
    fireEvent.click(getByTestId(name))
    expect(pushMock).toHaveBeenCalled()
    expect(wave.args[name]).toBe(name)
  })

  it('Makes card unclickable if name was not provided', () => {
    tallInfoProps.state.name = ''
    const { getByTestId } = render(<View {...tallInfoProps} />)
    fireEvent.click(getByTestId(name))
    expect(pushMock).not.toHaveBeenCalled()
    expect(wave.args[name]).not.toBe(name)
  })

  it('Makes only the button (label) clickable if label was provided', () => {
    tallInfoProps.state.label = 'Click me'
    const { getByText, getByTestId } = render(<View {...tallInfoProps} />)
    fireEvent.click(getByTestId(name))
    expect(pushMock).not.toHaveBeenCalled()
    expect(wave.args[name]).not.toBe(name)

    fireEvent.click(getByText('Click me'))
    expect(pushMock).toHaveBeenCalled()
    expect(wave.args[name]).toBe(name)
  })
})

Review comment (suggestion):
Name is required, so it always has to be provided.
```suggestion
  it('Makes card unclickable if name is empty', () => {
```

Code after:
  })

  it('Does not submit data to server if name specified but starts with #', () => {
    tallInfoProps.state.name = `#${name}`
    const { getByTestId } = render(<View {...tallInfoProps} />)
    fireEvent.click(getByTestId(name))
    expect(pushMock).not.toHaveBeenCalled()
    expect(wave.args[name]).toBeUndefined()
  })

  it('Submits data to server if name specified without #', () => {
    tallInfoProps.state.name = name
    const { getByTestId } = render(<View {...tallInfoProps} />)
    fireEvent.click(getByTestId(name))
    expect(pushMock).toHaveBeenCalled()
    expect(wave.args[name]).toBe(name)
  })

  it('Makes card clickable only if name was specified but label was not', () => {
    const { getByTestId } = render(<View {...tallInfoProps} />)
    fireEvent.click(getByTestId(name))
    expect(pushMock).toHaveBeenCalled()
    expect(wave.args[name]).toBe(name)
  })

  it('Makes card unclickable if name is empty', () => {
    tallInfoProps.state.name = ''
    const { getByTestId } = render(<View {...tallInfoProps} />)
    fireEvent.click(getByTestId(name))
    expect(pushMock).not.toHaveBeenCalled()
    expect(wave.args[name]).not.toBe(name)
  })

  it('Makes only the button (label) clickable if label was provided', () => {
    tallInfoProps.state.label = 'Click me'
    const { getByText, getByTestId } = render(<View {...tallInfoProps} />)
    fireEvent.click(getByTestId(name))
    expect(pushMock).not.toHaveBeenCalled()
    expect(wave.args[name]).not.toBe(name)

    fireEvent.click(getByText('Click me'))
    expect(pushMock).toHaveBeenCalled()
    expect(wave.args[name]).toBe(name)
  })
})