@quilted/react-testing
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -279,4 +279,4 @@ "use strict"; | ||
context = act(function () { | ||
return env.mount( /*#__PURE__*/_react["default"].createElement(_TestRenderer.TestRenderer, { | ||
act(function () { | ||
context = env.mount( /*#__PURE__*/_react["default"].createElement(_TestRenderer.TestRenderer, { | ||
ref: function ref(renderer) { | ||
@@ -283,0 +283,0 @@ testRenderer.current = renderer; |
@@ -34,3 +34,3 @@ "use strict"; | ||
var renderer = _ref2.renderer; | ||
return createNodeFromTree(renderer.toTree(), create); | ||
return createNodeFromTestInstance(renderer.root, create); | ||
} | ||
@@ -48,14 +48,14 @@ }), | ||
function createNodeFromTree(element, create) { | ||
var _element$children$map, _element$children; | ||
function createNodeFromTestInstance(testInstance, create) { | ||
var _testInstance$childre; | ||
var children = (_element$children$map = (_element$children = element.children) === null || _element$children === void 0 ? void 0 : _element$children.map(function (child) { | ||
return typeof child === 'string' ? child : createNodeFromTree(child, create); | ||
})) !== null && _element$children$map !== void 0 ? _element$children$map : []; | ||
var children = (_testInstance$childre = testInstance.children.map(function (child) { | ||
return typeof child === 'string' ? child : createNodeFromTestInstance(child, create); | ||
})) !== null && _testInstance$childre !== void 0 ? _testInstance$childre : []; | ||
return create({ | ||
props: element.props, | ||
type: element.type, | ||
props: testInstance.props, | ||
type: testInstance.type, | ||
children: children, | ||
instance: element.instance | ||
instance: testInstance.instance | ||
}); | ||
} |
@@ -147,8 +147,10 @@ "use strict"; | ||
context = act(() => env.mount( /*#__PURE__*/_react.default.createElement(_TestRenderer.TestRenderer, { | ||
ref: renderer => { | ||
testRenderer.current = renderer; | ||
}, | ||
render: render | ||
}, element))); | ||
act(() => { | ||
context = env.mount( /*#__PURE__*/_react.default.createElement(_TestRenderer.TestRenderer, { | ||
ref: renderer => { | ||
testRenderer.current = renderer; | ||
}, | ||
render: render | ||
}, element)); | ||
}); | ||
allMounted.add(root); | ||
@@ -155,0 +157,0 @@ mounted = true; |
@@ -42,3 +42,3 @@ "use strict"; | ||
}) { | ||
return createNodeFromTree(renderer.toTree(), create); | ||
return createNodeFromTestInstance(renderer.root, create); | ||
} | ||
@@ -52,12 +52,12 @@ | ||
function createNodeFromTree(element, create) { | ||
var _element$children$map, _element$children; | ||
function createNodeFromTestInstance(testInstance, create) { | ||
var _testInstance$childre; | ||
const children = (_element$children$map = (_element$children = element.children) === null || _element$children === void 0 ? void 0 : _element$children.map(child => typeof child === 'string' ? child : createNodeFromTree(child, create))) !== null && _element$children$map !== void 0 ? _element$children$map : []; | ||
const children = (_testInstance$childre = testInstance.children.map(child => typeof child === 'string' ? child : createNodeFromTestInstance(child, create))) !== null && _testInstance$childre !== void 0 ? _testInstance$childre : []; | ||
return create({ | ||
props: element.props, | ||
type: element.type, | ||
props: testInstance.props, | ||
type: testInstance.type, | ||
children, | ||
instance: element.instance | ||
instance: testInstance.instance | ||
}); | ||
} |
@@ -115,5 +115,7 @@ "use strict"; | ||
} | ||
context = act(() => env.mount(react_1.default.createElement(TestRenderer_1.TestRenderer, { ref: (renderer) => { | ||
testRenderer.current = renderer; | ||
}, render: render }, element))); | ||
act(() => { | ||
context = env.mount(react_1.default.createElement(TestRenderer_1.TestRenderer, { ref: (renderer) => { | ||
testRenderer.current = renderer; | ||
}, render: render }, element)); | ||
}); | ||
allMounted.add(root); | ||
@@ -120,0 +122,0 @@ mounted = true; |
@@ -17,3 +17,3 @@ "use strict"; | ||
update(_, create, { renderer }) { | ||
return createNodeFromTree(renderer.toTree(), create); | ||
return createNodeFromTestInstance(renderer.root, create); | ||
}, | ||
@@ -25,11 +25,13 @@ }); | ||
exports.unmountAll = unmountAll; | ||
function createNodeFromTree(element, create) { | ||
var _a, _b; | ||
const children = (_b = (_a = element.children) === null || _a === void 0 ? void 0 : _a.map((child) => typeof child === 'string' ? child : createNodeFromTree(child, create))) !== null && _b !== void 0 ? _b : []; | ||
function createNodeFromTestInstance(testInstance, create) { | ||
var _a; | ||
const children = (_a = testInstance.children.map((child) => typeof child === 'string' | ||
? child | ||
: createNodeFromTestInstance(child, create))) !== null && _a !== void 0 ? _a : []; | ||
return create({ | ||
props: element.props, | ||
type: element.type, | ||
props: testInstance.props, | ||
type: testInstance.type, | ||
children, | ||
instance: element.instance, | ||
instance: testInstance.instance, | ||
}); | ||
} |
{ | ||
"name": "@quilted/react-testing", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "", | ||
@@ -30,3 +30,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "0be58c6037f42284d3ef3542f39244f76f4fcd59" | ||
"gitHead": "f44735e6d04d98a609004a395d382f77fda65e46" | ||
} |
@@ -5,3 +5,3 @@ import { | ||
ReactTestRenderer, | ||
ReactTestRendererJSON, | ||
ReactTestInstance, | ||
} from 'react-test-renderer'; | ||
@@ -30,3 +30,3 @@ | ||
update(_, create, {renderer}) { | ||
return createNodeFromTree(renderer.toTree()!, create) as any; | ||
return createNodeFromTestInstance(renderer.root, create) as any; | ||
}, | ||
@@ -37,16 +37,18 @@ }); | ||
function createNodeFromTree( | ||
element: ReactTestRendererJSON, | ||
function createNodeFromTestInstance( | ||
testInstance: ReactTestInstance, | ||
create: Create, | ||
): ReturnType<Create> { | ||
const children = | ||
element.children?.map((child) => | ||
typeof child === 'string' ? child : createNodeFromTree(child, create), | ||
testInstance.children.map((child) => | ||
typeof child === 'string' | ||
? child | ||
: createNodeFromTestInstance(child, create), | ||
) ?? []; | ||
return create<unknown>({ | ||
props: element.props, | ||
type: element.type, | ||
props: testInstance.props, | ||
type: testInstance.type, | ||
children, | ||
instance: (element as any).instance, | ||
instance: testInstance.instance, | ||
}); | ||
@@ -53,0 +55,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6854
679683