Skip to content

Commit

Permalink
fix MultiInputField test
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyaochen authored and shiyaochen committed Feb 6, 2025
1 parent caf9a50 commit ae35542
Showing 1 changed file with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { COLORS } from '@opentrons/components'
import { fireEvent, screen } from '@testing-library/react'
import { i18n } from '../../../../../../../assets/localization'
import { renderWithProviders } from '../../../../../../../__testing-utils__'
import { MultiInputField } from '../MultiInputField'

import type { ComponentProps } from 'react'
import { COLORS } from '@opentrons/components'

const render = (props: ComponentProps<typeof MultiInputField>) => {
return renderWithProviders(<MultiInputField {...props} />, {
Expand All @@ -24,12 +24,12 @@ describe('MultiInputField', () => {
fields: [
{
fieldTitle: 'submerge speed',
fieldKey: 'submerge_speed',
fieldKey: 'aspirate_submerge_speed',
units: 'mm/s',
},
{
fieldTitle: 'submerge delay seconds',
fieldKey: 'submerge_delay_seconds',
fieldKey: 'aspirate_submerge_delay_seconds',
units: 'mm',
},
],
Expand All @@ -43,6 +43,15 @@ describe('MultiInputField', () => {
updateValue: vi.fn(),
value: null,
},
aspirate_submerge_delay_seconds: {
onFieldFocus: vi.fn(),
onFieldBlur: vi.fn(),
errorToShow: null,
disabled: false,
name: 'aspirate_submerge_delay_seconds',
updateValue: vi.fn(),
value: '',
},
},
}
})
Expand All @@ -60,13 +69,18 @@ describe('MultiInputField', () => {
const inputs = screen.getAllByRole('textbox', { name: '' })
expect(inputs).toHaveLength(2)
fireEvent.change(inputs[0], { target: { value: ['5'] } })
fireEvent.change(inputs[0], { target: { value: ['5'] } })
expect(
props.propsForFields.aspirate_submerge_speed.updateValue
).toHaveBeenCalled()
fireEvent.change(inputs[1], { target: { value: ['10'] } })
expect(
props.propsForFields.aspirate_submerge_delay_seconds.updateValue
).toHaveBeenCalled()
})

it('should render a well position listbutton when isWellPosition is true', () => {
props.isWellPosition = true
render(props)
})
// it('should render a well position listbutton when isWellPosition is true', () => {
// props.isWellPosition = true
// render(props)
// })
})

0 comments on commit ae35542

Please sign in to comment.