( framework: string, harness: ComponentHarness, components: CustomCheckpointComponents, )
| 453 | }; |
| 454 | |
| 455 | export 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 | ); |
no test coverage detected
searching dependent graphs…