Skip to content

Instantly share code, notes, and snippets.

@ryanswrt
Last active July 25, 2019 04:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanswrt/69ca377dd94dc37f6efeb3ac72b3fd36 to your computer and use it in GitHub Desktop.
Save ryanswrt/69ca377dd94dc37f6efeb3ac72b3fd36 to your computer and use it in GitHub Desktop.
import { renderHook, act } from '@testing-library/react-hooks';
import { useWavelet } from 'react-use-wavelet';
describe('react-use-wavelet', () => {
test('throw when invalid host is passed', async () => {
// render a dummy component that uses our hook
const { result, waitForNextUpdate } = renderHook(() =>
useWavelet('break')
);
// as our client is instantiated in an async effect,
// we need to wait for it to complete before we get results
await waitForNextUpdate();
// read the current return values from the hook
const [client, node, error] = result.current();
// we should have an error, and no client
expect(error).toBeTruthy();
expect(client).toBeFalsy();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment