NuxtN
Nuxt2y ago
Tumulte

registerEndpoint requires multiple flushPromises

registerEndpoint('/api/channel/1', {
  method: 'DELETE',
  handler: () => {
    return {};
  },
});

describe('ChannelMenu', () => {
  it('deletes a channel', async () => {
    const wrapper = mountWrapper();
    const deleteState = useState(DELETE_CHANNEL_ID);
    wrapper.vm.deleteChannel();
    await flushPromises();
    await flushPromises();

    expect(deleteState.value).toBe(wrapper.vm.props.channel.idChannel);
  });
});

take this code for instance... if I only use 1 flushPromises, the expect won't work.

Is it expected ?
Is there a workaround ?

thanks !
Was this page helpful?