/* eslint-disable max-lines */ import React from 'react' import type { PicassoConfig } from '@toptal/picasso-test-utils' import { render } from '@toptal/picasso-test-utils' import type { OmitInternalProps } from '@toptal/picasso-shared' import { NativeSelect } from './NativeSelect' import type { SelectProps } from '../SelectBase' const renderNativeSelect = ( props: OmitInternalProps, picassoConfig?: PicassoConfig ) => { const { options, value, width, placeholder, multiple = false, onChange = () => {}, renderOption, getDisplayValue, ...rest } = props return render( , undefined, picassoConfig ) } const OPTIONS = [ { key: 1, value: 'val1', text: 'text1', }, { key: 2, value: 'val2', text: 'text2', }, { key: 3, value: 'val3', text: 'text3', }, ] describe('NativeSelect', () => { it('renders native select', () => { const { container, getByText } = renderNativeSelect({ options: OPTIONS, placeholder: 'Choose an option...', value: 'val1', }) const emptyOption = getByText('Choose an option...') expect(emptyOption).toBeDisabled() expect(container).toMatchSnapshot() }) it('renders native select with the empty option enabled when enableReset is `true`', () => { const { container, getByText } = renderNativeSelect({ enableReset: true, options: OPTIONS, placeholder: 'Choose an option...', value: 'val1', }) const emptyOption = getByText('Choose an option...') expect(emptyOption).not.toBeDisabled() expect(container).toMatchSnapshot() }) })