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

Code before:
  })

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

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

  it('Makes card unclickable if name was not provided', () => {
    wideInfoProps.state.name = ''
    const { getByTestId } = render(<View {...wideInfoProps} />)
    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', () => {
    wideInfoProps.state.label = 'Click me'
    const { getByText, getByTestId } = render(<View {...wideInfoProps} />)
    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):
```suggestion
  it('Makes card unclickable if name is empty', () => {
```

Code after:
  })

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

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

  it('Makes card unclickable if name is empty', () => {
    wideInfoProps.state.name = ''
    const { getByTestId } = render(<View {...wideInfoProps} />)
    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', () => {
    wideInfoProps.state.label = 'Click me'
    const { getByText, getByTestId } = render(<View {...wideInfoProps} />)
    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)
  })
})