Total Complexity | 2 |
Complexity/F | 2 |
Lines of Code | 47 |
Function Count | 1 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import React from "react" |
||
2 | import expectRender from "../expect-to-same-render"; |
||
3 | import type { ClassHash } from "./defs"; |
||
4 | import { classNamesMap } from "."; |
||
5 | import type { GridOptions } from "ag-grid-community"; |
||
6 | |||
7 | type ThirdPartyComponentProps = { |
||
8 | checked?: boolean |
||
9 | ContainerClassName?: string |
||
10 | CheckedClassName?: string |
||
11 | NotCheckedClassName?: string |
||
12 | } |
||
13 | |||
14 | function ThirdPartyComponent({ |
||
15 | checked, |
||
16 | ContainerClassName, |
||
17 | CheckedClassName, |
||
18 | NotCheckedClassName, |
||
19 | }: ThirdPartyComponentProps ) { |
||
20 | return <div className={ContainerClassName}> |
||
21 | <div className={checked ? CheckedClassName : NotCheckedClassName}/> |
||
22 | </div> |
||
23 | } |
||
24 | |||
25 | const classnames = {Root: "App", "Item--active": "hash1"} as Record<"Root"|"Theme--dark"|"Item--active", ClassHash> |
||
26 | , {Root} = classnames |
||
27 | , mapping = classNamesMap(classnames) |
||
28 | |||
29 | it("demo", () => expectRender( |
||
30 | <ThirdPartyComponent checked={true} {...mapping<ThirdPartyComponentProps>({ |
||
31 | ContainerClassName: {Root, "Theme--dark": true}, |
||
32 | CheckedClassName: {"Item--active": true} |
||
33 | })}/> |
||
34 | ).toSame( |
||
35 | <div className="App Theme--dark"> |
||
36 | <div className="hash1"/> |
||
37 | </div> |
||
38 | )) |
||
39 | |||
40 | it("AgGrid", () => expect( |
||
41 | mapping<GridOptions>({ |
||
42 | rowClass: {Root, "Item--active": true}, |
||
43 | }) |
||
44 | ).toStrictEqual({ |
||
45 | rowClass: "App hash1" |
||
46 | })) |
||
47 | |||
48 |