mirror of
https://github.com/zhigang1992/react-native-web.git
synced 2026-04-28 20:34:52 +08:00
33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
/* eslint-env jasmine, jest */
|
|
|
|
import NetInfo from '..';
|
|
|
|
describe('apis/NetInfo', () => {
|
|
describe('isConnected', () => {
|
|
const handler = () => {};
|
|
|
|
afterEach(() => {
|
|
try { NetInfo.isConnected.removeEventListener('change', handler); } catch (e) {}
|
|
});
|
|
|
|
describe('addEventListener', () => {
|
|
test('throws if the provided "eventType" is not supported', () => {
|
|
expect(() => NetInfo.isConnected.addEventListener('foo', handler)).toThrow();
|
|
expect(() => NetInfo.isConnected.addEventListener('change', handler)).not.toThrow();
|
|
});
|
|
});
|
|
|
|
describe('removeEventListener', () => {
|
|
test('throws if the handler is not registered', () => {
|
|
expect(() => NetInfo.isConnected.removeEventListener('change', handler)).toThrow;
|
|
});
|
|
|
|
test('throws if the provided "eventType" is not supported', () => {
|
|
NetInfo.isConnected.addEventListener('change', handler);
|
|
expect(() => NetInfo.isConnected.removeEventListener('foo', handler)).toThrow;
|
|
expect(() => NetInfo.isConnected.removeEventListener('change', handler)).not.toThrow;
|
|
});
|
|
});
|
|
});
|
|
});
|