0

i try to create a simple test who :

  • click on button
  • show if dropdown is open

i try to simulate a click with trigger but it is not working, do you have any idea what i am doing wrong?

    describe('test clique boutton filtre', () => {
  test('should show dropdown de la colonne 1', async (done) => {
    const dropdown = wrapper.find('#nom-divUpperDrop')
    const button = wrapper.find('#nom-dropdown')

    await button.trigger('click')

    expect(dropdown.findAll('.show').length).equal(1)
    done()
  })
})

i'am sure i find the button because the console log show :

<button type="button" id="nom-dropdown" data-bs-toggle="dropdown" aria-bs-haspopup="true" aria-bs-expanded="false" data-bs-offset="-60,10" data-bs-auto-close="outside" class="nav-icon clear-btn">
      <p> false </p>
    </button>

here the dropdown where i want to find the .show

> <div aria-labelledby="nom-dropdown" class="dropdown-menu">
>         <div>
>           <div class="filter-deroulant">
>             <!---->
>             <div class="filter-input">
>               <div class="input-group mb-3"><input type="text" id="filtre_0" value="" placeholder="Recherche par nom"
> aria-label="Rechercher" aria-describedby="nom" class="form-control col
> form-control-sm"> <button type="button" id="nom" class="btn
> btn-outline-secondary"><svg aria-hidden="true" focusable="false"
> data-prefix="fas" data-icon="search" role="img"
> xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"
> aria-expanded="false" class="svg-inline--fa fa-search fa-w-16">
>                     <path fill="currentColor" d="M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0
> 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4
> 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z"
> class=""></path>
>                   </svg></button></div>
>             </div>
>           </div>
>         </div>
>         <div>

Any idea?

ps: i tried this : Vue Testing (JEST): button.trigger('click') not working

ps: I tried the button manually, it's work :)

but it's not working for me

0 Answers0