mirror of
https://github.com/streamich/react-use.git
synced 2025-12-08 18:02:14 +00:00
Improved hook performance, now works with safari. BREAKING CHANGE: `useNetwork` hook renamed to `useNetworkState`.
27 lines
672 B
TypeScript
27 lines
672 B
TypeScript
import { renderHook } from '@testing-library/react-hooks';
|
|
import { useNetworkState } from '../src';
|
|
|
|
//ToDo: improve tests
|
|
describe(`useNetworkState`, () => {
|
|
it('should be defined', () => {
|
|
expect(useNetworkState).toBeDefined();
|
|
});
|
|
|
|
it('should return an object of certain structure', () => {
|
|
const hook = renderHook(() => useNetworkState(), { initialProps: false });
|
|
|
|
expect(typeof hook.result.current).toEqual('object');
|
|
expect(Object.keys(hook.result.current)).toEqual([
|
|
'online',
|
|
'previous',
|
|
'since',
|
|
'downlink',
|
|
'downlinkMax',
|
|
'effectiveType',
|
|
'rtt',
|
|
'saveData',
|
|
'type',
|
|
]);
|
|
});
|
|
});
|