react-component-instance 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -8
- package/package.json +1 -1
- package/src/container/index.mjs +2 -1
- package/src/index.mjs +2 -1
- package/tsconfig.json +0 -14
package/README.md
CHANGED
|
@@ -11,17 +11,28 @@ import getInstance from 'react-component-instance'
|
|
|
11
11
|
**Note** that for use with _Testing Library_ import from `react-component-instance/container`
|
|
12
12
|
|
|
13
13
|
```javascript
|
|
14
|
-
import getInstance from 'react-component-instance/container'
|
|
15
|
-
|
|
16
14
|
import {
|
|
17
15
|
render
|
|
18
16
|
} from '@testing-library/react'
|
|
19
17
|
|
|
20
|
-
|
|
21
|
-
container
|
|
22
|
-
} = render(
|
|
23
|
-
<Component />
|
|
24
|
-
)
|
|
18
|
+
import getInstance from 'react-component-instance/container'
|
|
25
19
|
|
|
26
|
-
|
|
20
|
+
describe('`getInstance`', () => {
|
|
21
|
+
class Component extends React.Component {
|
|
22
|
+
render () {
|
|
23
|
+
return <div />
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
it('gets the instance', () => {
|
|
28
|
+
const {
|
|
29
|
+
container
|
|
30
|
+
} = render(
|
|
31
|
+
<Component />
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
expect(getInstance(container))
|
|
35
|
+
.toBeInstanceOf(Component)
|
|
36
|
+
})
|
|
37
|
+
})
|
|
27
38
|
```
|
package/package.json
CHANGED
package/src/container/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @typedef {import('@testing-library/react').RenderResult} RenderType
|
|
2
3
|
* @typedef {ReactComponentInstanceTypes.FiberRootNode} FiberRootNode
|
|
3
4
|
*/
|
|
4
5
|
|
|
@@ -21,7 +22,7 @@ export function getContainerFiberNodeFrom (container) {
|
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
|
-
* @param {
|
|
25
|
+
* @param {RenderType} component
|
|
25
26
|
* @returns {Element | null}
|
|
26
27
|
*/
|
|
27
28
|
export function getComponentElement ({
|
package/src/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @typedef {import('@testing-library/react').RenderResult} RenderType
|
|
2
3
|
* @typedef {ReactComponentInstanceTypes.FiberNode} FiberNode
|
|
3
4
|
*/
|
|
4
5
|
|
|
@@ -87,7 +88,7 @@ export function getChildFiberNodeFrom (element) {
|
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
/**
|
|
90
|
-
* @param {
|
|
91
|
+
* @param {RenderType} component
|
|
91
92
|
* @returns {Element | null}
|
|
92
93
|
*/
|
|
93
94
|
export function getComponentElement ({
|