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

100% Statements 12/12
100% Branches 0/0
100% Functions 2/2
100% Lines 11/11

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
    4330x
    30x
    30x
    30x

    30x

    30x
    176x
    176x

    30x

    176x

    30x
     import * as React from 'react'
    import * as PropTypes from 'prop-types'
    import { render, RenderOptions, RenderResult } from '@testing-library/react'
    import { SheetsRegistry } from '@fluent-ui/styles'
    import { StyleSheet } from 'jss'
    import { ThemeProvider } from '../ThemeProvider'

    interface WrapperProps {
      children?: React.ReactNode
    }

    interface MySheetsRegistry extends SheetsRegistry {
      registry: StyleSheet[] | any
    }

    let sheets: MySheetsRegistry

    const Wrapper: React.FC<WrapperProps> = ({ children }): React.ReactElement => {
      sheets = new SheetsRegistry() as MySheetsRegistry
      return (
        <ThemeProvider theme={{}} registry={sheets}>
          {children}
        </ThemeProvider>
      )
    }
    Wrapper.propTypes = {
      children: PropTypes.node
    }

    interface Result extends RenderResult {
      sheets: MySheetsRegistry
    }

    const customRender = (ui: React.ReactElement, options?: RenderOptions): Result => ({
      ...render(ui, {
        wrapper: Wrapper,
        ...options
      }),
      sheets
    })

    export { customRender as render }