MCPcopy
hub / github.com/tinyplex/tinybase / testDefaultAndNamed

Function testDefaultAndNamed

test/unit/core/ui-common/components.ts:644–671  ·  view source on GitHub ↗
(
      name: string,
      component: unknown,
      thing: () => Thing,
      defaultProps: (thing: Thing) => {[key: string]: unknown},
      namedProps: (thing: Thing) => {[key: string]: unknown},
      expected: string,
    )

Source from the content-addressed store, hash-verified

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(

Callers 1

testProviderComponentsFunction · 0.85

Calls 3

testFunction · 0.50
thingFunction · 0.50
renderMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…