# All files / src/test-utils render.tsx

100% Statements 45/45
100% Branches 2/2
100% Functions 2/2
100% Lines 45/45

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    461x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    171x
    171x
    171x
    171x
    171x
    171x
    171x
    171x
    171x
    171x
    171x
    171x
    285x
    285x
    285x
    285x
    285x
    285x
    171x
    171x
     import {
      render,
      type Queries,
      type RenderOptions,
      type RenderResult,
      type queries,
    } from "@testing-library/react";
    import { Fragment, type ReactElement } from "react";
    import { CoreProviders, type CoreProvidersProps } from "../CoreProviders.js";

    /**
     * @remarks \@since 6.0.0
     */
    export interface ReactMDRenderOptions<
      Q extends Queries = typeof queries,
      Container extends Element | DocumentFragment = HTMLElement,
      BaseElement extends Element | DocumentFragment = Container,
    > extends RenderOptions<Q, Container, BaseElement> {
      rmdConfig?: Omit<CoreProvidersProps, "children">;
    }

    /**
     * @remarks \@since 6.0.0
     */
    export function rmdRender<
      Q extends Queries = typeof queries,
      Container extends Element | DocumentFragment = HTMLElement,
      BaseElement extends Element | DocumentFragment = Container,
    >(
      ui: ReactElement,
      options: ReactMDRenderOptions<Q, Container, BaseElement> = {}
    ): RenderResult<Q, Container, BaseElement> {
      const { wrapper: Wrapper = Fragment, rmdConfig, ...renderOptions } = options;

      return render(ui, {
        ...renderOptions,
        wrapper: function ReactMDTestWrapper(props) {
          return (
            <CoreProviders {...rmdConfig}>
              <Wrapper>{props.children}</Wrapper>
            </CoreProviders>
          );
        },
      });
    }