( framework: string, harness: FunctionHarness, components: FunctionComponents, )
| 2082 | }; |
| 2083 | |
| 2084 | export const testWriteCallbackFunctions = ( |
| 2085 | framework: string, |
| 2086 | harness: FunctionHarness, |
| 2087 | components: FunctionComponents, |
| 2088 | ): void => { |
| 2089 | let store: Store; |
| 2090 | let queries: Queries; |
| 2091 | let checkpoints: Checkpoints; |
| 2092 | |
| 2093 | beforeEach(() => { |
| 2094 | store = createStore() |
| 2095 | .setTables({t1: {r1: {c1: 1}}}) |
| 2096 | .setValues({v1: 1}); |
| 2097 | queries = createQueries(store).setQueryDefinition('q1', 't1', ({select}) => |
| 2098 | select('c1'), |
| 2099 | ); |
| 2100 | checkpoints = createCheckpoints(store); |
| 2101 | }); |
| 2102 | |
| 2103 | describe(`${framework} write callback scenarios`, () => { |
| 2104 | test('setRow', async () => { |
| 2105 | const then = vi.fn(); |
| 2106 | const {container, unmount} = renderWriter(harness, components, 'setRow', { |
| 2107 | store, |
| 2108 | then, |
| 2109 | }); |
| 2110 | |
| 2111 | await harness.act(() => |
| 2112 | container.querySelector<HTMLButtonElement>('button')?.click(), |
| 2113 | ); |
| 2114 | expect(store.getRow('t1', 'r1')).toEqual({c1: 2}); |
| 2115 | expect(then).toHaveBeenCalledTimes(1); |
| 2116 | |
| 2117 | unmount(); |
| 2118 | }); |
| 2119 | |
| 2120 | test('setTables', async () => { |
| 2121 | const then = vi.fn(); |
| 2122 | const {container, unmount} = renderWriter( |
| 2123 | harness, |
| 2124 | components, |
| 2125 | 'setTables', |
| 2126 | {store, then}, |
| 2127 | ); |
| 2128 | |
| 2129 | await harness.act(() => |
| 2130 | container.querySelector<HTMLButtonElement>('button')?.click(), |
| 2131 | ); |
| 2132 | expect(store.getTables()).toEqual({t1: {r1: {c1: 2}}}); |
| 2133 | expect(then).toHaveBeenCalledTimes(1); |
| 2134 | |
| 2135 | unmount(); |
| 2136 | }); |
| 2137 | |
| 2138 | test('setTable', async () => { |
| 2139 | const then = vi.fn(); |
| 2140 | const {container, unmount} = renderWriter( |
| 2141 | harness, |
no test coverage detected
searching dependent graphs…