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

Code before:
      expect(window.location.hash).toBe('#command1')
      expect(pushMock).toHaveBeenCalledTimes(0)
      expect(wave.args['#command1']).toBe(false)
    })

    it('Does not render commands when link specified', () => {
      const btnLinkProps: Buttons = {
        items: [{
          button: {
            name,
            label: name,
            link: true,
            commands: [
              { name: 'command1', label: 'Command 1' },
              { name: 'command2', label: 'Command 2' },
            ]
          }
        }]
      }
      const { container, getByTestId } = render(<XButtons model={btnLinkProps} />)

      expect(getByTestId(name)).toHaveClass('ms-Link')
      expect(container.querySelector('i[data-icon-name="ChevronDown"]') as HTMLLIElement).not.toBeInTheDocument()
    })

    it('Does not set args and calls sync on click when command has download link specified', () => {
      const
        btnCommandDownloadProps: Buttons = {
          items: [{
            button: {
              name,
              label: name,
              commands: [
                { name: 'command1', label: 'Command 1' },
                { name: 'command2', label: 'Command 2', path, download: true },
              ]
            }
          }]
        },
        { container, getByText } = render(<XButtons model={btnCommandDownloadProps} />),
        contextMenuButton = container.querySelector('i[data-icon-name="ChevronDown"]') as HTMLLIElement

      expect(wave.args['command1']).toBe(false)
      fireEvent.click(contextMenuButton)
      fireEvent.click(getByText('Command 1'))
      expect(wave.args['command1']).toBe(true)

      expect(pushMock).toHaveBeenCalled()
      expect(pushMock).toHaveBeenCalledTimes(1)

      expect(wave.args['command2']).toBe(false)

Review comment (suggestion):
```suggestion
    it('Does not set args or calls sync on click when command has download link specified', () => {
```

Code after:
      expect(window.location.hash).toBe('#command1')
      expect(pushMock).toHaveBeenCalledTimes(0)
      expect(wave.args['#command1']).toBe(false)
    })

    it('Does not render commands when link specified', () => {
      const btnLinkProps: Buttons = {
        items: [{
          button: {
            name,
            label: name,
            link: true,
            commands: [
              { name: 'command1', label: 'Command 1' },
              { name: 'command2', label: 'Command 2' },
            ]
          }
        }]
      }
      const { container, getByTestId } = render(<XButtons model={btnLinkProps} />)

      expect(getByTestId(name)).toHaveClass('ms-Link')
      expect(container.querySelector('i[data-icon-name="ChevronDown"]') as HTMLLIElement).not.toBeInTheDocument()
    })

    it('Does not set args or calls sync on click when command has download link specified', () => {
      const
        btnCommandDownloadProps: Buttons = {
          items: [{
            button: {
              name,
              label: name,
              commands: [
                { name: 'command1', label: 'Command 1' },
                { name: 'command2', label: 'Command 2', path, download: true },
              ]
            }
          }]
        },
        { container, getByText } = render(<XButtons model={btnCommandDownloadProps} />),
        contextMenuButton = container.querySelector('i[data-icon-name="ChevronDown"]') as HTMLLIElement

      expect(wave.args['command1']).toBe(false)
      fireEvent.click(contextMenuButton)
      fireEvent.click(getByText('Command 1'))
      expect(wave.args['command1']).toBe(true)

      expect(pushMock).toHaveBeenCalled()
      expect(pushMock).toHaveBeenCalledTimes(1)

      expect(wave.args['command2']).toBe(false)