-
-
Save ryanswrt/69ca377dd94dc37f6efeb3ac72b3fd36 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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