@quilted/react-testing
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -59,10 +59,17 @@ "use strict"; | ||
function createNode({ | ||
type, | ||
props, | ||
instance, | ||
children, | ||
...extensions | ||
}) { | ||
const finalExtensions = extensions; | ||
function createNode(createOptions) { | ||
const { | ||
type, | ||
props, | ||
instance, | ||
children | ||
} = createOptions; // We can’t just pick the remaining properties off `createOptions` with the | ||
// spread operator, because that attempts to invoke any getters in extensions | ||
// (including ones like .domNodes that may throw errors) | ||
const extensionPropertyDescriptors = Object.getOwnPropertyDescriptors(createOptions); | ||
delete extensionPropertyDescriptors.type; | ||
delete extensionPropertyDescriptors.props; | ||
delete extensionPropertyDescriptors.instance; | ||
delete extensionPropertyDescriptors.type; | ||
const descendants = children.flatMap(getDescendants); | ||
@@ -145,3 +152,3 @@ | ||
Object.defineProperties(node, { ...Object.getOwnPropertyDescriptors(baseNode), | ||
...Object.getOwnPropertyDescriptors(finalExtensions) | ||
...extensionPropertyDescriptors | ||
}); | ||
@@ -148,0 +155,0 @@ return node; |
"use strict"; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -49,5 +38,12 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
return root; | ||
function createNode(_a) { | ||
var { type, props, instance, children } = _a, extensions = __rest(_a, ["type", "props", "instance", "children"]); | ||
const finalExtensions = extensions; | ||
function createNode(createOptions) { | ||
const { type, props, instance, children } = createOptions; | ||
// We can’t just pick the remaining properties off `createOptions` with the | ||
// spread operator, because that attempts to invoke any getters in extensions | ||
// (including ones like .domNodes that may throw errors) | ||
const extensionPropertyDescriptors = Object.getOwnPropertyDescriptors(createOptions); | ||
delete extensionPropertyDescriptors.type; | ||
delete extensionPropertyDescriptors.props; | ||
delete extensionPropertyDescriptors.instance; | ||
delete extensionPropertyDescriptors.type; | ||
const descendants = children.flatMap(getDescendants); | ||
@@ -111,3 +107,3 @@ function getDescendants(child) { | ||
const node = {}; | ||
Object.defineProperties(node, Object.assign(Object.assign({}, Object.getOwnPropertyDescriptors(baseNode)), Object.getOwnPropertyDescriptors(finalExtensions))); | ||
Object.defineProperties(node, Object.assign(Object.assign({}, Object.getOwnPropertyDescriptors(baseNode)), extensionPropertyDescriptors)); | ||
return node; | ||
@@ -114,0 +110,0 @@ } |
@@ -8,9 +8,9 @@ /// <reference types="react" /> | ||
export type { Node, HtmlNodeExtensions, CustomMount }; | ||
declare const mount: <Props>(element: import("react").ReactElement<Props, string | ((props: any) => import("react").ReactElement<any, string | any | (new (props: any) => import("react").Component<any, any, any>)> | null) | (new (props: any) => import("react").Component<any, any, any>)>) => import("../types").NodeApi<Props, HtmlNodeExtensions> & Pick<HtmlNodeExtensions, "text" | "data" | "html" | "isDom" | "domNodes" | "domNode"> & import("../types").Root<Props, undefined>, createMount: <MountOptions extends object = {}, Context_1 extends object = {}, Async extends boolean = false>({ render, context: createContext, afterMount, }: { | ||
declare const mount: <Props>(element: import("react").ReactElement<Props, string | ((props: any) => import("react").ReactElement<any, string | any | (new (props: any) => import("react").Component<any, any, any>)> | null) | (new (props: any) => import("react").Component<any, any, any>)>) => import("../types").NodeApi<Props, HtmlNodeExtensions> & Pick<HtmlNodeExtensions, "data" | "html" | "text" | "isDom" | "domNodes" | "domNode"> & import("../types").Root<Props, undefined>, createMount: <MountOptions extends object = {}, Context_1 extends object = {}, Async extends boolean = false>({ render, context: createContext, afterMount, }: { | ||
render(element: import("react").ReactElement<any, string | ((props: any) => import("react").ReactElement<any, string | any | (new (props: any) => import("react").Component<any, any, any>)> | null) | (new (props: any) => import("react").Component<any, any, any>)>, context: Context_1, options: MountOptions): import("react").ReactElement<any, string | ((props: any) => import("react").ReactElement<any, string | any | (new (props: any) => import("react").Component<any, any, any>)> | null) | (new (props: any) => import("react").Component<any, any, any>)>; | ||
} & import("../environment").ContextOption<MountOptions, Context_1> & (Async extends true ? { | ||
afterMount(wrapper: import("../types").NodeApi<unknown, HtmlNodeExtensions> & Pick<HtmlNodeExtensions, "text" | "data" | "html" | "isDom" | "domNodes" | "domNode"> & import("../types").Root<unknown, Context_1>, options: MountOptions): PromiseLike<void>; | ||
afterMount(wrapper: import("../types").NodeApi<unknown, HtmlNodeExtensions> & Pick<HtmlNodeExtensions, "data" | "html" | "text" | "isDom" | "domNodes" | "domNode"> & import("../types").Root<unknown, Context_1>, options: MountOptions): PromiseLike<void>; | ||
} : { | ||
afterMount?(wrapper: import("../types").NodeApi<unknown, HtmlNodeExtensions> & Pick<HtmlNodeExtensions, "text" | "data" | "html" | "isDom" | "domNodes" | "domNode"> & import("../types").Root<unknown, Context_1>, options: MountOptions): void; | ||
})) => CustomMount<MountOptions, Context_1, HtmlNodeExtensions, Async>, mounted: Set<import("../types").NodeApi<any, HtmlNodeExtensions> & Pick<HtmlNodeExtensions, "text" | "data" | "html" | "isDom" | "domNodes" | "domNode"> & import("../types").Root<any, any>>, unmountAll: () => void; | ||
afterMount?(wrapper: import("../types").NodeApi<unknown, HtmlNodeExtensions> & Pick<HtmlNodeExtensions, "data" | "html" | "text" | "isDom" | "domNodes" | "domNode"> & import("../types").Root<unknown, Context_1>, options: MountOptions): void; | ||
})) => CustomMount<MountOptions, Context_1, HtmlNodeExtensions, Async>, mounted: Set<import("../types").NodeApi<any, HtmlNodeExtensions> & Pick<HtmlNodeExtensions, "data" | "html" | "text" | "isDom" | "domNodes" | "domNode"> & import("../types").Root<any, any>>, unmountAll: () => void; | ||
export { mount, createMount, mounted, unmountAll }; | ||
@@ -17,0 +17,0 @@ /** |
@@ -7,9 +7,9 @@ /// <reference types="react" /> | ||
export type { Node, HtmlNodeExtensions, CustomMount }; | ||
declare const mount: <Props>(element: import("react").ReactElement<Props, string | ((props: any) => import("react").ReactElement<any, string | any | (new (props: any) => import("react").Component<any, any, any>)> | null) | (new (props: any) => import("react").Component<any, any, any>)>) => import("../types").NodeApi<Props, HtmlNodeExtensions> & Pick<HtmlNodeExtensions, "text" | "data" | "html" | "isDom" | "domNodes" | "domNode"> & import("../types").Root<Props, undefined>, createMount: <MountOptions extends object = {}, Context_1 extends object = {}, Async extends boolean = false>({ render, context: createContext, afterMount, }: { | ||
declare const mount: <Props>(element: import("react").ReactElement<Props, string | ((props: any) => import("react").ReactElement<any, string | any | (new (props: any) => import("react").Component<any, any, any>)> | null) | (new (props: any) => import("react").Component<any, any, any>)>) => import("../types").NodeApi<Props, HtmlNodeExtensions> & Pick<HtmlNodeExtensions, "data" | "html" | "text" | "isDom" | "domNodes" | "domNode"> & import("../types").Root<Props, undefined>, createMount: <MountOptions extends object = {}, Context_1 extends object = {}, Async extends boolean = false>({ render, context: createContext, afterMount, }: { | ||
render(element: import("react").ReactElement<any, string | ((props: any) => import("react").ReactElement<any, string | any | (new (props: any) => import("react").Component<any, any, any>)> | null) | (new (props: any) => import("react").Component<any, any, any>)>, context: Context_1, options: MountOptions): import("react").ReactElement<any, string | ((props: any) => import("react").ReactElement<any, string | any | (new (props: any) => import("react").Component<any, any, any>)> | null) | (new (props: any) => import("react").Component<any, any, any>)>; | ||
} & import("../environment").ContextOption<MountOptions, Context_1> & (Async extends true ? { | ||
afterMount(wrapper: import("../types").NodeApi<unknown, HtmlNodeExtensions> & Pick<HtmlNodeExtensions, "text" | "data" | "html" | "isDom" | "domNodes" | "domNode"> & import("../types").Root<unknown, Context_1>, options: MountOptions): PromiseLike<void>; | ||
afterMount(wrapper: import("../types").NodeApi<unknown, HtmlNodeExtensions> & Pick<HtmlNodeExtensions, "data" | "html" | "text" | "isDom" | "domNodes" | "domNode"> & import("../types").Root<unknown, Context_1>, options: MountOptions): PromiseLike<void>; | ||
} : { | ||
afterMount?(wrapper: import("../types").NodeApi<unknown, HtmlNodeExtensions> & Pick<HtmlNodeExtensions, "text" | "data" | "html" | "isDom" | "domNodes" | "domNode"> & import("../types").Root<unknown, Context_1>, options: MountOptions): void; | ||
})) => CustomMount<MountOptions, Context_1, HtmlNodeExtensions, Async>, mounted: Set<import("../types").NodeApi<any, HtmlNodeExtensions> & Pick<HtmlNodeExtensions, "text" | "data" | "html" | "isDom" | "domNodes" | "domNode"> & import("../types").Root<any, any>>, unmountAll: () => void; | ||
afterMount?(wrapper: import("../types").NodeApi<unknown, HtmlNodeExtensions> & Pick<HtmlNodeExtensions, "data" | "html" | "text" | "isDom" | "domNodes" | "domNode"> & import("../types").Root<unknown, Context_1>, options: MountOptions): void; | ||
})) => CustomMount<MountOptions, Context_1, HtmlNodeExtensions, Async>, mounted: Set<import("../types").NodeApi<any, HtmlNodeExtensions> & Pick<HtmlNodeExtensions, "data" | "html" | "text" | "isDom" | "domNodes" | "domNode"> & import("../types").Root<any, any>>, unmountAll: () => void; | ||
export { mount, createMount, mounted, unmountAll }; | ||
@@ -16,0 +16,0 @@ declare type Create = Parameters<Environment<any, HtmlNodeExtensions>['update']>[1]; |
{ | ||
"name": "@quilted/react-testing", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "", | ||
@@ -65,3 +65,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "18df3f19c567cbf4de5e25315b83bf35b00da803" | ||
"gitHead": "929623eaddca79d04741881ea45a6d04f9c80e0c" | ||
} |
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
647393
5267