dimanche 24 novembre 2019

How can click twice same position in React testing?

I am writing test code. I don't know how to make test code with @testing-library/react. Scenario is
1. click and open select
2. click open target
3. click again without mouse moving
4. I want to look whether error occur

      const {getByRole}=render(
        <Autocomplete
        multiple
        filterSelectedOptions
        disableCloseOnSelect
        options={[{
          value:"one",
          label:"one"
        },{
          value:"two",
          label:"two"
        }
        ]}
        getOptionLabel={option => option.value}
        defaultValue={[]}
        renderInput={params => (
          <TextField
            {...params}
            fullWidth
          />
        )}
      /> 
      );
      const textbox = getByRole('textbox')
      fireEvent.click(textbox)
      fireEvent.click(textbox)
      expect(textbox).to.have.attribute('data-option-index',-1)
    })

Aucun commentaire:

Enregistrer un commentaire