This repository was archived by the owner on May 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathindex.spec.tsx
57 lines (48 loc) · 1.8 KB
/
index.spec.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity.
//
// SPDX-License-Identifier: MIT
import 'symbol-observable'; // TODO Remove this once https://github.com/acdlite/recompose/pull/660 is merged
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import * as React from 'react';
import * as Adapter from 'enzyme-adapter-react-16';
import * as Enzyme from 'enzyme';
import { of } from 'rxjs';
import { toClass } from 'recompose';
import light, { withOneObservable } from './';
Enzyme.configure({ adapter: new Adapter() });
const { mount } = Enzyme;
const MockComponent = toClass(props => (
<div>{JSON.stringify(props)}</div>
)) as any;
const mockRpc$ = () => of('bar');
describe('withOneObservable', () => {
test('it should return a HOC', () => {
expect(typeof withOneObservable('foo', () => of('bar'))).toBe('function');
});
test('it should give the wrapped component the correct props', () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const EnhancedComponent = withOneObservable('foo', mockRpc$)(MockComponent);
const wrapper = mount(<EnhancedComponent />);
const div = wrapper.find('div');
expect(div.text()).toEqual(JSON.stringify({ foo: 'bar' }));
});
});
describe('light', () => {
test('it should return a HOC', () => {
expect(
typeof light({
foo: mockRpc$
})
).toBe('function');
});
test('it should give the wrapped component the correct props', () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const EnhancedComponent = light({ foo: mockRpc$, baz: mockRpc$ })(
MockComponent
);
const wrapper = mount(<EnhancedComponent />);
const div = wrapper.find('div');
expect(div.text()).toEqual(JSON.stringify({ foo: 'bar', baz: 'bar' }));
});
});