( framework: string, harness: FunctionHarness, components: FunctionComponents, )
| 1947 | }; |
| 1948 | |
| 1949 | export 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', []]); |
no test coverage detected
searching dependent graphs…