Passed
Push — main ( 3322df...b61daa )
by Andrii
02:05
created

__tests__/map.spec.tsx   A

Complexity

Total Complexity 2
Complexity/F 2

Size

Lines of Code 47
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 36
mnd 1
bc 1
fnc 1
dl 0
loc 47
rs 10
bpm 1
cpm 2
noi 0
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A map.spec.tsx ➔ ThirdPartyComponent 0 5 2
1
import React from "react"
2
import expectRender from "../expect-to-same-render";
3
import type { ClassHash } from "../src/defs";
4
import { classNamesMap } from "../src";
5
import { Tooltip } from "reactstrap";
6
7
const classnames = {Root: "App", "Item--active": "hash1"} as Record<"Root"|"Theme--dark"|"Item--active", ClassHash>
8
, {Root} = classnames
9
, mapping = classNamesMap(classnames)
10
11
it("Some Component", () => {
12
  type ThirdPartyComponentProps = {
13
    checked?: boolean
14
    ContainerClassName?: string
15
    CheckedClassName?: string
16
    NotCheckedClassName?: string
17
  }  
18
  function ThirdPartyComponent({ checked, ContainerClassName, CheckedClassName, NotCheckedClassName}: ThirdPartyComponentProps ) {
19
    return <div className={ContainerClassName}>
20
      <div className={checked ? CheckedClassName : NotCheckedClassName}/>
21
    </div>
22
  }
23
  
24
  expectRender(
25
    <ThirdPartyComponent checked={true} {...mapping<ThirdPartyComponentProps>({
26
      ContainerClassName: {Root, "Theme--dark": true},
27
      CheckedClassName: {"Item--active": true},
28
      //@ts-expect-error Object literal may only specify known properties, and 'NotExistentProperty' does not exist
29
      NotExistentProperty: {"Theme--dark": true}
30
    })}/>
31
  ).toSame(
32
    <div className="App Theme--dark">
33
      <div className="hash1"/>
34
    </div>
35
  )
36
})
37
38
it("reactstrap Tooltip", () => expectRender(
39
  <Tooltip target="target" {...mapping<typeof Tooltip>({
40
    className: {Root},
41
    popperClassName: {"Theme--dark": true},
42
    innerClassName: {"Item--active": true},
43
  })}/>
44
).toSame(
45
  // No static render
46
))
47
48