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

100% Statements 18/18
87.5% Branches 7/8
100% Functions 2/2
100% Lines 18/18

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

    30x

    30x

    30x

    30x

    30x
    37x
    37x
    267x
    267x
    8x
    8x

    259x
    37x

    222x

    37x

     import * as React from 'react'
    import { render, getClasses } from './index'
    import '@testing-library/jest-dom/extend-expect'

    import Box, { name } from '../Box/Box'
    import { BoxClassProps } from '../Box/Box.type'
    import { styles } from '../Box/Box.styled'

    const testText = 'Hello World'

    const classes = getClasses<BoxClassProps>(styles, name)

    export function getStyle(props: any): any {
      const { sheets } = render(<Box {...props}>{testText}</Box>)
      const result = sheets.registry[0].rules.index.reduce((acc: any, cur: any) => {
        const rule = cur
        if (rule.at === 'media') {
          Eif (Object.keys(rule.rules.index[0].style).length) {
            return {
              ...acc,
              [rule.key]: rule.rules.index[0].style
            }
          }
        } else if (classes.system.includes(rule.id) && !!Object.keys(rule.style).length) {
          return {
            ...acc,
            ...rule.style
          }
        }
        return acc
      }, {})
      return result
    }