( framework: string, harness: FunctionHarness, components: FunctionComponents, )
| 189 | }; |
| 190 | |
| 191 | export const testStoreReadFunctions = ( |
| 192 | framework: string, |
| 193 | harness: FunctionHarness, |
| 194 | components: FunctionComponents, |
| 195 | ): void => { |
| 196 | let store: Store; |
| 197 | |
| 198 | beforeEach(() => { |
| 199 | store = createStore() |
| 200 | .setTables({t1: {r1: {c1: 1}}}) |
| 201 | .setValues({v1: 1}); |
| 202 | }); |
| 203 | |
| 204 | describe(`${framework} store read function scenarios`, () => { |
| 205 | test('hasTables', async () => { |
| 206 | const {container, unmount} = renderReader( |
| 207 | harness, |
| 208 | components, |
| 209 | 'hasTables', |
| 210 | {store}, |
| 211 | ); |
| 212 | expect(container.textContent).toEqual('true'); |
| 213 | |
| 214 | await harness.act(() => store.delTables()); |
| 215 | expect(container.textContent).toEqual('false'); |
| 216 | |
| 217 | unmount(); |
| 218 | }); |
| 219 | |
| 220 | test('getTables', async () => { |
| 221 | const {container, unmount} = renderReader(harness, components, 'tables', { |
| 222 | store, |
| 223 | }); |
| 224 | expect(container.textContent).toEqual( |
| 225 | JSON.stringify({t1: {r1: {c1: 1}}}), |
| 226 | ); |
| 227 | |
| 228 | await harness.act(() => |
| 229 | store.setTables({t1: {r1: {c1: 2}}}).setTables({t1: {r1: {c1: 2}}}), |
| 230 | ); |
| 231 | expect(container.textContent).toEqual( |
| 232 | JSON.stringify({t1: {r1: {c1: 2}}}), |
| 233 | ); |
| 234 | |
| 235 | await harness.act(() => store.delTables()); |
| 236 | expect(container.textContent).toEqual(JSON.stringify({})); |
| 237 | |
| 238 | unmount(); |
| 239 | }); |
| 240 | |
| 241 | test('getTableIds', async () => { |
| 242 | const {container, unmount} = renderReader( |
| 243 | harness, |
| 244 | components, |
| 245 | 'tableIds', |
| 246 | {store}, |
| 247 | ); |
| 248 | expect(container.textContent).toEqual(JSON.stringify(['t1'])); |
no test coverage detected
searching dependent graphs…