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

Function testStateFunctions

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

Source from the content-addressed store, hash-verified

86) => harness.render(components.Writer, {mode, ...props});
87
88export const testStateFunctions = (
89 framework: string,
90 harness: FunctionHarness,
91 components: FunctionComponents,
92): void => {
93 let store: Store;
94 let queries: Queries;
95
96 beforeEach(() => {
97 store = createStore()
98 .setTables({t1: {r1: {c1: 1}}})
99 .setValues({v1: 1});
100 queries = createQueries(store).setQueryDefinition(
101 'q1',
102 't1',
103 ({select, where, param}) => {
104 select('c1');
105 where('c1', param('p1') as Cell);
106 },
107 {p1: 1},
108 );
109 });
110
111 describe(`${framework} state function scenarios`, () => {
112 [
113 {
114 mode: 'tablesState',
115 before: {t1: {r1: {c1: 1}}},
116 after: {t1: {r1: {c1: 2}}},
117 getProps: () => ({store}),
118 assert: () => expect(store.getCell('t1', 'r1', 'c1')).toEqual(2),
119 },
120 {
121 mode: 'tableState',
122 before: {r1: {c1: 1}},
123 after: {r1: {c1: 2}},
124 getProps: () => ({store}),
125 assert: () => expect(store.getCell('t1', 'r1', 'c1')).toEqual(2),
126 },
127 {
128 mode: 'rowState',
129 before: {c1: 1},
130 after: {c1: 2},
131 getProps: () => ({store}),
132 assert: () => expect(store.getRow('t1', 'r1')).toEqual({c1: 2}),
133 },
134 {
135 mode: 'cellState',
136 before: 1,
137 after: 2,
138 getProps: () => ({store}),
139 assert: () => expect(store.getCell('t1', 'r1', 'c1')).toEqual(2),
140 },
141 {
142 mode: 'valuesState',
143 before: {v1: 1},
144 after: {v1: 2},
145 getProps: () => ({store}),

Callers 2

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

Calls 14

createStoreFunction · 0.90
renderStateFunction · 0.85
setValuesMethod · 0.65
setTablesMethod · 0.65
setQueryDefinitionMethod · 0.65
getCellMethod · 0.65
getRowMethod · 0.65
getValueMethod · 0.65
getParamValueMethod · 0.65
selectFunction · 0.50
whereFunction · 0.50
paramFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…