Passed
Branch main (393d41)
by Andrii
04:53 queued 02:15
created

expect-to-same-render.ts   A

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 19
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 12
mnd 0
bc 0
fnc 1
dl 0
loc 19
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
rs 10
1
import {renderToStaticMarkup} from "react-dom/server"
2
3
type RElement = Parameters<typeof renderToStaticMarkup>[0]
4
5
export default expectRender
6
7
function expectRender(
8
  ...elements: RElement[]
9
) {
10
  return {
11
    toSame: (...expectations: RElement[]) => 
12
      expect(
13
        elements.map(renderToStaticMarkup).join("")
14
      ).toBe(
15
        expectations.map(renderToStaticMarkup).join("")
16
      )
17
  }
18
}
19