MCPcopy Index your code
hub / github.com/tinyplex/tinybase / testCheckpointCallbackFunctions

Function testCheckpointCallbackFunctions

test/unit/core/ui-common/functions.ts:1949–2011  ·  view source on GitHub ↗
(
  framework: string,
  harness: FunctionHarness,
  components: FunctionComponents,
)

Source from the content-addressed store, hash-verified

1947};
1948
1949export const testCheckpointCallbackFunctions = (
1950 framework: string,
1951 harness: FunctionHarness,
1952 components: FunctionComponents,
1953): void => {
1954 let store: Store;
1955 let checkpoints: Checkpoints;
1956
1957 beforeEach(() => {
1958 store = createStore().setTables({t1: {r1: {c1: 1}}});
1959 checkpoints = createCheckpoints(store);
1960 store.setTables({t1: {r1: {c1: 2}}});
1961 checkpoints.addCheckpoint();
1962 store.setTables({t1: {r1: {c1: 3}}});
1963 checkpoints.addCheckpoint();
1964 });
1965
1966 describe(`${framework} checkpoint callback scenarios`, () => {
1967 test('goBackward', async () => {
1968 const {container, unmount} = renderCallback(
1969 harness,
1970 components,
1971 'goBackward',
1972 {checkpoints},
1973 );
1974
1975 await harness.act(() =>
1976 container.querySelector<HTMLButtonElement>('button')?.click(),
1977 );
1978 expect(checkpoints.getCheckpointIds()).toEqual([['0'], '1', ['2']]);
1979
1980 await harness.act(() =>
1981 container.querySelector<HTMLButtonElement>('button')?.click(),
1982 );
1983 expect(checkpoints.getCheckpointIds()).toEqual([[], '0', ['1', '2']]);
1984
1985 unmount();
1986 });
1987
1988 test('goForward', async () => {
1989 const {container, unmount} = renderCallback(
1990 harness,
1991 components,
1992 'goForward',
1993 {checkpoints},
1994 );
1995
1996 checkpoints.goTo('0');
1997
1998 await harness.act(() =>
1999 container.querySelector<HTMLButtonElement>('button')?.click(),
2000 );
2001 expect(checkpoints.getCheckpointIds()).toEqual([['0'], '1', ['2']]);
2002
2003 await harness.act(() =>
2004 container.querySelector<HTMLButtonElement>('button')?.click(),
2005 );
2006 expect(checkpoints.getCheckpointIds()).toEqual([['0', '1'], '2', []]);

Callers 3

hooks.test.tsxFile · 0.90
primitives.test.tsFile · 0.90
functions.test.tsFile · 0.90

Calls 7

createStoreFunction · 0.90
renderCallbackFunction · 0.85
setTablesMethod · 0.65
addCheckpointMethod · 0.65
getCheckpointIdsMethod · 0.65
goToMethod · 0.65
testFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…