| Total Complexity | 1 |
| Complexity/F | 1 |
| Lines of Code | 37 |
| 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 classNaming from "../src" |
||
| 4 | |||
| 5 | it("Basic usage", () => { |
||
| 6 | type Props = { |
||
| 7 | isValid: boolean |
||
| 8 | readOnly: boolean |
||
| 9 | } |
||
| 10 | |||
| 11 | // isValid = false, readOnly = false |
||
| 12 | function FormButtons({isValid, readOnly}: Props) { |
||
| 13 | const cssClasses = classNaming() |
||
| 14 | const buttonClass = cssClasses({"button": true}) // "button" |
||
| 15 | |||
| 16 | return <> |
||
| 17 | <button { |
||
| 18 | ...buttonClass // className="button" |
||
| 19 | }>Close</button> |
||
| 20 | <button type="reset" { |
||
| 21 | ...buttonClass({"button--disabled": readOnly}) // className="button" |
||
| 22 | }>Reset</button> |
||
| 23 | <button type="submit" className={`button_submit ${ |
||
| 24 | buttonClass({"button--disabled": readOnly || !isValid}) // "button button--disabled" |
||
| 25 | }`}>Submit</button> |
||
| 26 | </> |
||
| 27 | } |
||
| 28 | |||
| 29 | expectRender( |
||
| 30 | <FormButtons isValid={false} readOnly={false} /> |
||
| 31 | ).toSame(<> |
||
| 32 | <button className="button">Close</button> |
||
| 33 | <button type="reset" className="button">Reset</button> |
||
| 34 | <button type="submit" className="button_submit button button--disabled">Submit</button> |
||
| 35 | </>) |
||
| 36 | }) |
||
| 37 |