MCPcopy
hub / github.com/tinyplex/tinybase / testStoreReadFunctions

Function testStoreReadFunctions

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

Source from the content-addressed store, hash-verified

189};
190
191export 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']));

Callers 3

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

Calls 15

createStoreFunction · 0.90
renderReaderFunction · 0.85
setValuesMethod · 0.65
setTablesMethod · 0.65
delTablesMethod · 0.65
setTableMethod · 0.65
delTableMethod · 0.65
setRowMethod · 0.65
delValuesMethod · 0.65
setMetricDefinitionMethod · 0.65
delMetricDefinitionMethod · 0.65
setCellMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…