react-component-snapshot 0.0.1 → 0.0.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.mjs +18 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-component-snapshot",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Transform a React component to match its snapshot in Jest",
5
5
  "keywords": [
6
6
  "react",
package/src/index.mjs CHANGED
@@ -47,8 +47,8 @@ export function getReactPropsKey (stateNode) {
47
47
  }
48
48
 
49
49
  /**
50
- * @param {Element | Text | React.Component<any, any, any>} stateNode
51
- * @returns {Record<PropertyKey, unknown> | null}
50
+ * @param {Element | Text | React.Component<any, any, any>} stateNode
51
+ * @returns {Record<PropertyKey, unknown> | null}
52
52
  */
53
53
  export function getStateNodeFiber (stateNode) {
54
54
  const key = getReactFiberKey(stateNode)
@@ -65,8 +65,8 @@ export function getStateNodeFiber (stateNode) {
65
65
  }
66
66
 
67
67
  /**
68
- * @param {React.Component<any, any, any> | Element | Text} stateNode
69
- * @returns {Record<PropertyKey, unknown> | null}
68
+ * @param {React.Component<any, any, any> | Element | Text} stateNode
69
+ * @returns {Record<PropertyKey, unknown> | null}
70
70
  */
71
71
  export function getStateNodeProps (stateNode) {
72
72
  const key = getReactPropsKey(stateNode)
@@ -82,6 +82,18 @@ export function getStateNodeProps (stateNode) {
82
82
  return null
83
83
  }
84
84
 
85
+ /**
86
+ * @param {{ container: { firstElementChild: Element | null } }} component
87
+ * @returns {Element | null}
88
+ */
89
+ export function getComponentElement ({
90
+ container: {
91
+ firstElementChild: element
92
+ }
93
+ }) {
94
+ return element
95
+ }
96
+
85
97
  /**
86
98
  * @param {Element} element
87
99
  * @returns {FiberNode | null}
@@ -220,8 +232,8 @@ function transform (fiberNode) {
220
232
  }
221
233
 
222
234
  /**
223
- * @param {Element | null | undefined} element
224
- * @returns {Record<PropertyKey, unknown> | null}
235
+ * @param {Element | null | undefined} element
236
+ * @returns {Record<PropertyKey, unknown> | null}
225
237
  */
226
238
  export default function snapshotOf (element) {
227
239
  if (element instanceof HTMLElement) {