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

Function testWriteCallbackFunctions

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

Source from the content-addressed store, hash-verified

2082};
2083
2084export 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,

Callers 2

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

Calls 15

createStoreFunction · 0.90
renderWriterFunction · 0.85
setValuesMethod · 0.65
setTablesMethod · 0.65
setQueryDefinitionMethod · 0.65
getRowMethod · 0.65
getTablesMethod · 0.65
getTableMethod · 0.65
getCellMethod · 0.65
getValuesMethod · 0.65
getValueMethod · 0.65
getParamValueMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…