<commit_before>import { Button } from '@hospitalrun/components'
import { render, screen } from '@testing-library/react'
import React from 'react'

import * as ButtonBarProvider from '../../../page-header/button-toolbar/ButtonBarProvider'
import ButtonToolBar from '../../../page-header/button-toolbar/ButtonToolBar'

describe('Button Tool Bar', () => {
  beforeEach(() => {
    jest.resetAllMocks()
  })

  it('should render the buttons in the provider', () => {
    const buttons: React.ReactNode[] = [
      <Button key="test1">Test 1</Button>,
      <Button key="test2">Test 2</Button>,
    ]
    jest.spyOn(ButtonBarProvider, 'useButtons').mockReturnValue(buttons)

    render(<ButtonToolBar />)
    const renderedButtons = screen.getAllByRole('button')

    expect(renderedButtons[0]).toHaveTextContent(/test 1/i)
    expect(renderedButtons[1]).toHaveTextContent(/test 2/i)
  })

  it('should return null when there is no button in the provider', () => {
    jest.spyOn(ButtonBarProvider, 'useButtons').mockReturnValue([])

    render(<ButtonToolBar />)
    expect(screen.queryAllByRole('button')).toHaveLength(0)
  })
})<commit_msg>Added as per review comments by Jacob<commit_after>import { Button } from '@hospitalrun/components'
import { render, screen } from '@testing-library/react'
import React from 'react'

import * as ButtonBarProvider from '../../../page-header/button-toolbar/ButtonBarProvider'
import ButtonToolBar from '../../../page-header/button-toolbar/ButtonToolBar'

describe('Button Tool Bar', () => {
  beforeEach(() => {
    jest.resetAllMocks()
  })

  it('should render the buttons in the provider', () => {
    const buttons: React.ReactNode[] = [
      <Button key="test1">Test 1</Button>,
      <Button key="test2">Test 2</Button>,
    ]
    jest.spyOn(ButtonBarProvider, 'useButtons').mockReturnValue(buttons)

    render(<ButtonToolBar />)
    const renderedButtons = screen.getAllByRole('button')

    expect(renderedButtons[0]).toHaveTextContent(/test 1/i)
    expect(renderedButtons[1]).toHaveTextContent(/test 2/i)
  })

  it('should return null when there is no button in the provider', () => {
    jest.spyOn(ButtonBarProvider, 'useButtons').mockReturnValue([])

    render(<ButtonToolBar />)
    expect(screen.queryByRole('button')).not.toBeInTheDocument()
  })
})
{'fraction_non_alphanumeric': 0.15921908893709327, 'fraction_numerical': 0.00737527114967462, 'mean_word_length': 4.240909090909091, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2142253', 'n_tokens_mistral': 701, 'n_tokens_neox': 688, 'n_words': 142}