@syncular/testkit 0.15.47 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +14 -14
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -37,16 +37,16 @@ test('two clients converge', async () => {
37
37
  const a = await sync.client('a');
38
38
  const b = await sync.client('b');
39
39
 
40
- const sub = { id: 's', table: 'notes', scopes: { list_id: ['welcome'] } };
40
+ const sub = { id: 's', table: 'todos', scopes: { list_id: ['groceries'] } };
41
41
  a.api.subscribe(sub);
42
42
  b.api.subscribe(sub);
43
43
 
44
44
  a.api.mutate([
45
- { table: 'notes', op: 'upsert', values: { id: 'n1', list_id: 'welcome', body: 'hi' } },
45
+ { table: 'todos', op: 'upsert', values: { id: 't1', list_id: 'groceries', title: 'hi' } },
46
46
  ]);
47
47
  await sync.syncAll(); // push A's outbox, pull it into B
48
48
 
49
- expect(b.api.query('SELECT body FROM notes')).toEqual([{ body: 'hi' }]);
49
+ expect(b.api.query('SELECT title FROM todos')).toEqual([{ title: 'hi' }]);
50
50
  await sync.dispose();
51
51
  });
52
52
  ```
@@ -102,10 +102,10 @@ await client.close()
102
102
 
103
103
  ```ts
104
104
  a.goOffline();
105
- a.api.mutate([{ table: 'notes', op: 'upsert', values: { id: 'n1', list_id: 'l', body: 'draft' } }]);
105
+ a.api.mutate([{ table: 'todos', op: 'upsert', values: { id: 't1', list_id: 'l', title: 'draft' } }]);
106
106
 
107
107
  // Visible locally (optimistic), but nothing leaves:
108
- expect(a.api.query('SELECT body FROM notes')).toEqual([{ body: 'draft' }]);
108
+ expect(a.api.query('SELECT title FROM todos')).toEqual([{ title: 'draft' }]);
109
109
  expect(a.api.pendingCommits()).toHaveLength(1);
110
110
  await expect(a.api.sync()).rejects.toThrow(); // offline
111
111
 
@@ -173,18 +173,18 @@ deterministic conflict—no timers or transport mocks are needed:
173
173
  ```ts
174
174
  await sync.syncAll();
175
175
  const [{ version }] = a.api.query(
176
- 'SELECT _sync_version AS version FROM notes WHERE id = ?',
177
- ['n1'],
176
+ 'SELECT _sync_version AS version FROM todos WHERE id = ?',
177
+ ['t1'],
178
178
  ) as Array<{ version: number }>;
179
179
 
180
- a.api.patch('notes', 'n1', { body: 'A' }, { baseVersion: version });
181
- b.api.patch('notes', 'n1', { body: 'B' }, { baseVersion: version });
180
+ a.api.patch('todos', 't1', { title: 'A' }, { baseVersion: version });
181
+ b.api.patch('todos', 't1', { title: 'B' }, { baseVersion: version });
182
182
 
183
183
  await a.sync(); // wins version + 1
184
184
  await b.sync(); // loses against the stale base
185
185
 
186
- expect(b.api.conflicts[0]?.serverRow.body).toBe('A');
187
- expect(b.api.conflicts[0]?.operation?.changedFields).toEqual(['body']);
186
+ expect(b.api.conflicts[0]?.serverRow.title).toBe('A');
187
+ expect(b.api.conflicts[0]?.operation?.changedFields).toEqual(['title']);
188
188
  ```
189
189
 
190
190
  Pass `validators` to `createTestSync` to exercise the same business rules as
@@ -213,16 +213,16 @@ import { syncWrapper } from '@syncular/testkit/react';
213
213
 
214
214
  const sync = await createTestSync({ schema });
215
215
  const client = await sync.client('a');
216
- client.api.subscribe({ id: 's', table: 'notes', scopes: { list_id: ['x'] } });
216
+ client.api.subscribe({ id: 's', table: 'todos', scopes: { list_id: ['x'] } });
217
217
  await client.sync();
218
218
 
219
219
  const { result } = renderHook(
220
- () => useRawSql('SELECT * FROM notes'),
220
+ () => useRawSql('SELECT * FROM todos'),
221
221
  { wrapper: syncWrapper(client) },
222
222
  );
223
223
 
224
224
  await act(async () => {
225
- client.api.mutate([{ table: 'notes', op: 'upsert', values: { id: 'n1', list_id: 'x', body: 'hi' } }]);
225
+ client.api.mutate([{ table: 'todos', op: 'upsert', values: { id: 't1', list_id: 'x', title: 'hi' } }]);
226
226
  });
227
227
  await waitFor(() => expect(result.current.rows).toHaveLength(1));
228
228
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syncular/testkit",
3
- "version": "0.15.47",
3
+ "version": "0.16.1",
4
4
  "description": "Syncular test kit: in-process loopback server + clients for integration scenarios",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Benjamin Kniffler",
@@ -64,8 +64,8 @@
64
64
  "test": "bun test --preload ./test/setup.ts"
65
65
  },
66
66
  "dependencies": {
67
- "@syncular/server": "0.15.47",
68
- "@syncular/client": "0.15.47"
67
+ "@syncular/server": "0.16.1",
68
+ "@syncular/client": "0.16.1"
69
69
  },
70
70
  "peerDependencies": {
71
71
  "react": ">=18.0.0"
@@ -77,7 +77,7 @@
77
77
  },
78
78
  "devDependencies": {
79
79
  "@happy-dom/global-registrator": "^20.0.0",
80
- "@syncular/react": "0.15.47",
80
+ "@syncular/react": "0.16.1",
81
81
  "@testing-library/react": "^16.1.0",
82
82
  "@types/react": "^18.3.0",
83
83
  "react": "^18.3.1",