Passed
Push — main ( 4fe5eb...9915cc )
by Andrii
02:23
created

expect-to-render.ts   A

Complexity

Total Complexity 2
Complexity/F 2

Size

Lines of Code 19
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 14
mnd 1
bc 1
fnc 1
dl 0
loc 19
bpm 1
cpm 2
noi 0
c 0
b 0
f 0
rs 10
1
import {renderToStaticMarkup} from "react-dom/server"
2
3
const {isArray: $isArray} = Array
4
5
export default expectToRender
6
7
function expectToRender(
8
  element: Parameters<typeof renderToStaticMarkup>[0],
9
  expectation: string | string[] 
10
) {
11
  return expect(
12
    renderToStaticMarkup(element)
13
  ).toBe(
14
    !$isArray(expectation)
15
    ? expectation
16
    : expectation.join("")
17
  )
18
}
19