Skip to content

Commit a33fd43

Browse files
committed
chore: add powerplug on tests
1 parent 214e308 commit a33fd43

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"npm-run-all": "^4.1.2",
4747
"prettier": "^1.11.1",
4848
"react-dom": "^16.3.0",
49+
"react-powerplug": "^0.1.5",
4950
"ts-jest": "^22.4.2",
5051
"ts-node": "^5.0.1",
5152
"tslint": "^5.9.1",

src/index.test.tsx

+13-19
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,48 @@
11
import * as React from 'react'
22
import { shallow, mount } from 'enzyme'
3+
import { Value } from 'react-powerplug'
34

45
import { adopt } from './'
56

67
test('return one component with children props as function', () => {
7-
const Foo = ({ children }) =>
8-
children && typeof children === 'function' && children('foo')
9-
108
interface RenderProps {
11-
foo: string
9+
foo: { value: string }
1210
}
1311

1412
const Composed = adopt<RenderProps>({
15-
foo: <Foo />,
13+
foo: <Value initial="foo" />,
1614
})
1715

18-
const result = mount(<Composed>{props => <div>{props.foo}</div>}</Composed>)
16+
const result = mount(
17+
<Composed>{({ foo }) => <div>{foo.value}</div>}</Composed>
18+
)
1919
const { children } = result.props()
2020

2121
expect(children).toBeDefined()
2222
expect(typeof children).toBe('function')
2323
})
2424

2525
test('rendering children component', () => {
26-
const Foo = ({ children, tor }) =>
27-
children && typeof children === 'function' && children(tor + 'foo')
28-
29-
const Bar = ({ render, tor }) =>
30-
render && typeof render === 'function' && render(tor + 'bar')
31-
3226
interface RenderProps {
33-
foo: 'foo'
34-
bar: 'bar'
27+
foo: { value: string }
28+
bar: { value: string }
3529
}
3630

3731
interface Props {
3832
tor: string
3933
}
4034

4135
const Composed = adopt<RenderProps, Props>({
42-
bar: ({ tor, render }) => <Bar tor={tor} render={render} />,
43-
foo: ({ tor, render }) => <Foo tor={tor}>{render}</Foo>,
36+
foo: ({ tor, render }) => <Value initial={tor + 'foo'}>{render}</Value>,
37+
bar: ({ tor, render }) => <Value initial={tor + 'bar'}>{render}</Value>,
4438
})
4539

4640
const result = shallow(
4741
<Composed tor="tor">
48-
{props => (
42+
{({ foo, bar }) => (
4943
<div>
50-
<div>{props.foo}</div>
51-
<div>{props.bar}</div>
44+
<div>{foo.value}</div>
45+
<div>{bar.value}</div>
5246
</div>
5347
)}
5448
</Composed>

yarn.lock

+4
Original file line numberDiff line numberDiff line change
@@ -4234,6 +4234,10 @@ react-is@^16.3.0:
42344234
version "16.3.0"
42354235
resolved "https://registry.npmjs.org/react-is/-/react-is-16.3.0.tgz#f0e8bfd8c09b480dd610b8639d9ed65c13601224"
42364236

4237+
react-powerplug@^0.1.5:
4238+
version "0.1.5"
4239+
resolved "https://registry.npmjs.org/react-powerplug/-/react-powerplug-0.1.5.tgz#f3dd7612c60efc55b6c7a2ddee284a8bcb6db783"
4240+
42374241
react-reconciler@^0.7.0:
42384242
version "0.7.0"
42394243
resolved "https://registry.npmjs.org/react-reconciler/-/react-reconciler-0.7.0.tgz#9614894103e5f138deeeb5eabaf3ee80eb1d026d"

0 commit comments

Comments
 (0)