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

Function testProviderComponents

test/unit/core/ui-common/components.ts:527–892  ·  view source on GitHub ↗
(
  framework: string,
  harness: ComponentHarness,
  components: ProviderComponents,
)

Source from the content-addressed store, hash-verified

525};
526
527export const testProviderComponents = (
528 framework: string,
529 harness: ComponentHarness,
530 components: ProviderComponents,
531): void => {
532 let store: Store;
533
534 beforeEach(() => {
535 store = createTestStore();
536 });
537
538 describe(`${framework} provider component scenarios`, () => {
539 if (components.Store != null) {
540 describe('store', () => {
541 test.each([
542 [
543 'tables',
544 // eslint-disable-next-line max-len
545 '1234{"t1":{"r1":{"c1":1}},"t2":{"r1":{"c1":2},"r2":{"c1":3,"c2":4}}}',
546 () => store.setTables({t1: {r1: {c1: 2}}}),
547 '2{"t1":{"r1":{"c1":2}}}',
548 () => store.delTables(),
549 '{}',
550 ],
551 [
552 'table',
553 '1{"r1":{"c1":1}}',
554 () => store.setTable('t1', {r1: {c1: 2}}),
555 '2{"r1":{"c1":2}}',
556 () => store.delTable('t1'),
557 '{}',
558 ],
559 [
560 'row',
561 '1{"c1":1}',
562 () => store.setRow('t1', 'r1', {c1: 2}),
563 '2{"c1":2}',
564 () => store.delRow('t1', 'r1'),
565 '{}',
566 ],
567 [
568 'cell',
569 '11',
570 () => store.setCell('t1', 'r1', 'c1', 2),
571 '22',
572 () => store.delCell('t1', 'r1', 'c1'),
573 '',
574 ],
575 ])(
576 'default %s',
577 async (mode, initial, update, updated, remove, removed) => {
578 const {container, unmount} = harness.render(components.Store, {
579 store,
580 mode,
581 });
582 expect(container.textContent).toEqual(initial);
583 await harness.act(update);
584 expect(container.textContent).toEqual(updated);

Callers 3

components.test.tsFile · 0.90

Calls 15

createLocalPersisterFunction · 0.90
createMergeableStoreFunction · 0.90
createStoreFunction · 0.90
createTestStoreFunction · 0.85
testDefaultAndNamedFunction · 0.85
setTablesMethod · 0.65
delTablesMethod · 0.65
setTableMethod · 0.65
delTableMethod · 0.65
setRowMethod · 0.65
delRowMethod · 0.65
setCellMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…