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

Function testCustomCheckpointComponents

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

Source from the content-addressed store, hash-verified

453};
454
455export const testCustomCheckpointComponents = (
456 framework: string,
457 harness: ComponentHarness,
458 components: CustomCheckpointComponents,
459): void => {
460 let store: Store;
461 let checkpoints: Checkpoints;
462
463 beforeEach(() => {
464 store = createTestStore();
465 checkpoints = createCheckpoints(store);
466 checkpoints.setCheckpoint('0', 'c1');
467 store.setTables({t1: {r1: {c1: 2}}});
468 checkpoints.addCheckpoint();
469 store.setTables({t1: {r1: {c1: 3}}});
470 checkpoints.addCheckpoint('c2');
471 store.setTables({t1: {r1: {c1: 4}}});
472 checkpoints.addCheckpoint('c3');
473 store.setTables({t1: {r1: {c1: 5}}});
474 checkpoints.addCheckpoint();
475 checkpoints.goTo('2');
476 });
477
478 describe(`${framework} custom checkpoint component scenarios`, () => {
479 test('all checkpoint views', async () => {
480 const {container, unmount} = harness.render(components.CheckpointsView, {
481 checkpoints,
482 });
483 await harness.act(() => checkpoints.clear());
484 expect(container.textContent).toEqual('||||');
485
486 await harness.act(() => checkpoints.setCheckpoint('0', 'c1'));
487 expect(container.textContent).toEqual('|c1|||');
488
489 await harness.act(() => store.setTables({t1: {r1: {c1: 2}}}));
490 expect(container.textContent).toEqual('c1||||');
491
492 await harness.act(() => checkpoints.addCheckpoint());
493 expect(container.textContent).toEqual('c1||||');
494
495 await harness.act(() => store.setTables({t1: {r1: {c1: 3}}}));
496 expect(container.textContent).toEqual('c1||||');
497
498 await harness.act(() => checkpoints.addCheckpoint('c2'));
499 expect(container.textContent).toEqual('c1|c2|||');
500
501 await harness.act(() => checkpoints.goTo('0'));
502 expect(container.textContent).toEqual('|c1|c2||');
503
504 unmount();
505 });
506
507 if (components.CurrentCheckpointView != null) {
508 test('current checkpoint custom renderer', async () => {
509 const {container, unmount} = harness.render(
510 components.CurrentCheckpointView,
511 {checkpoints},
512 );

Callers 3

components.test.tsFile · 0.90

Calls 8

createTestStoreFunction · 0.85
setCheckpointMethod · 0.65
setTablesMethod · 0.65
addCheckpointMethod · 0.65
goToMethod · 0.65
clearMethod · 0.65
testFunction · 0.50
renderMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…