(
name: string,
component: unknown,
thing: () => Thing,
defaultProps: (thing: Thing) => {[key: string]: unknown},
namedProps: (thing: Thing) => {[key: string]: unknown},
expected: string,
)
| 642 | } |
| 643 | |
| 644 | const testDefaultAndNamed = <Thing>( |
| 645 | name: string, |
| 646 | component: unknown, |
| 647 | thing: () => Thing, |
| 648 | defaultProps: (thing: Thing) => {[key: string]: unknown}, |
| 649 | namedProps: (thing: Thing) => {[key: string]: unknown}, |
| 650 | expected: string, |
| 651 | ) => { |
| 652 | test(`${name} default`, () => { |
| 653 | const createdThing = thing(); |
| 654 | const {container, unmount} = harness.render( |
| 655 | component, |
| 656 | defaultProps(createdThing), |
| 657 | ); |
| 658 | expect(container.textContent).toEqual(expected); |
| 659 | unmount(); |
| 660 | }); |
| 661 | |
| 662 | test(`${name} named`, () => { |
| 663 | const createdThing = thing(); |
| 664 | const {container, unmount} = harness.render( |
| 665 | component, |
| 666 | namedProps(createdThing), |
| 667 | ); |
| 668 | expect(container.textContent).toEqual(expected); |
| 669 | unmount(); |
| 670 | }); |
| 671 | }; |
| 672 | |
| 673 | if (components.Metrics != null) { |
| 674 | testDefaultAndNamed( |
no test coverage detected
searching dependent graphs…