diff --git a/src/__tests__/__snapshots__/test-utils-wrappers.test.tsx.snap b/src/__tests__/__snapshots__/test-utils-wrappers.test.tsx.snap index daab4f1..ae0bfd7 100644 --- a/src/__tests__/__snapshots__/test-utils-wrappers.test.tsx.snap +++ b/src/__tests__/__snapshots__/test-utils-wrappers.test.tsx.snap @@ -36,6 +36,15 @@ findCodeView(selector?: string): CodeViewWrapper | null; * @returns {Array} */ findAllCodeViews(selector?: string): Array; + +/** + * Returns the wrapper of the closest parent CodeView for the current element, + * or the element itself if it is an instance of CodeView. + * If no CodeView is found, returns \`null\`. + * + * @returns {CodeViewWrapper | null} + */ +findClosestCodeView(): CodeViewWrapper | null; } } @@ -54,6 +63,11 @@ ElementWrapper.prototype.findAllCodeViews = function(selector) { return this.findAllComponents(CodeViewWrapper, selector); }; +ElementWrapper.prototype.findClosestCodeView = function() { + // casting to 'any' is needed to avoid this issue with generics + // https://github.com/microsoft/TypeScript/issues/29132 + return (this as any).findClosestComponent(CodeViewWrapper); +}; export default function wrapper(root: Element = document.body) { if (document && document.body && !document.body.contains(root)) {