Skip to content

Commit 54671e2

Browse files
Remove misleading schema arguments (#1002) and backfill missing mock stubs (#1037)
* Remove misleading schema arguments (#1002) and backfill missing mock stubs. * ci: apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent c110b6c commit 54671e2

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

examples/react/todo/src/lib/collections.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ export const trailBaseTodoCollection = createCollection(
132132
trailBaseCollectionOptions<SelectTodo, Todo>({
133133
id: `todos`,
134134
getKey: (item) => item.id,
135-
schema: selectTodoSchema,
136135
recordApi: trailBaseClient.records(`todos`),
137136
// Re-using the example's drizzle-schema requires remapping the items.
138137
parse: {
@@ -233,7 +232,6 @@ export const trailBaseConfigCollection = createCollection(
233232
trailBaseCollectionOptions<SelectConfig, Config>({
234233
id: `config`,
235234
getKey: (item) => item.id,
236-
schema: selectConfigSchema,
237235
recordApi: trailBaseClient.records(`config`),
238236
// Re-using the example's drizzle-schema requires remapping the items.
239237
parse: {

examples/solid/todo/src/lib/collections.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ export const trailBaseTodoCollection = createCollection(
120120
trailBaseCollectionOptions<SelectTodo, Todo>({
121121
id: `todos`,
122122
getKey: (item) => item.id,
123-
schema: selectTodoSchema,
124123
recordApi: trailBaseClient.records(`todos`),
125124
// Re-using the example's drizzle-schema requires remapping the items.
126125
parse: {
@@ -215,7 +214,6 @@ export const trailBaseConfigCollection = createCollection(
215214
trailBaseCollectionOptions<SelectConfig, Config>({
216215
id: `config`,
217216
getKey: (item) => item.id,
218-
schema: selectConfigSchema,
219217
recordApi: trailBaseClient.records(`config`),
220218
// Re-using the example's drizzle-schema requires remapping the items.
221219
parse: {

packages/trailbase-db-collection/tests/trailbase.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,20 @@ import { describe, expect, it, vi } from 'vitest'
22
import { createCollection } from '@tanstack/db'
33
import { trailBaseCollectionOptions } from '../src/trailbase'
44
import type {
5+
CreateOperation,
6+
DeleteOperation,
57
Event,
68
FilterOrComposite,
9+
ListOperation,
10+
ListOpts,
711
ListResponse,
812
Pagination,
13+
ReadOperation,
14+
ReadOpts,
915
RecordApi,
16+
RecordId,
17+
SubscribeOpts,
18+
UpdateOperation,
1019
} from 'trailbase'
1120

1221
type Data = {
@@ -27,6 +36,9 @@ class MockRecordApi<T> implements RecordApi<T> {
2736
return Promise.resolve({ records: [] })
2837
},
2938
)
39+
listOp = vi.fn((_opts?: ListOpts): ListOperation<T> => {
40+
throw `listOp`
41+
})
3042

3143
read = vi.fn(
3244
(
@@ -38,20 +50,34 @@ class MockRecordApi<T> implements RecordApi<T> {
3850
throw `read`
3951
},
4052
)
53+
readOp = vi.fn((_id: RecordId, _opt?: ReadOpts): ReadOperation<T> => {
54+
throw `readOp`
55+
})
4156

4257
create = vi.fn((_record: T): Promise<string | number> => {
4358
throw `create`
4459
})
4560
createBulk = vi.fn((_records: Array<T>): Promise<Array<string | number>> => {
4661
throw `createBulk`
4762
})
63+
createOp = vi.fn((_record: T): CreateOperation<T> => {
64+
throw `createOp`
65+
})
4866

4967
update = vi.fn((_id: string | number, _record: Partial<T>): Promise<void> => {
5068
throw `update`
5169
})
70+
updateOp = vi.fn((_id: RecordId, _record: Partial<T>): UpdateOperation => {
71+
throw `updateOp`
72+
})
73+
5274
delete = vi.fn((_id: string | number): Promise<void> => {
5375
throw `delete`
5476
})
77+
deleteOp = vi.fn((_id: RecordId): DeleteOperation => {
78+
throw `deleteOp`
79+
})
80+
5581
subscribe = vi.fn((_id: string | number): Promise<ReadableStream<Event>> => {
5682
return Promise.resolve(
5783
new ReadableStream({
@@ -61,6 +87,11 @@ class MockRecordApi<T> implements RecordApi<T> {
6187
}),
6288
)
6389
})
90+
subscribeAll = vi.fn(
91+
(_opts?: SubscribeOpts): Promise<ReadableStream<Event>> => {
92+
throw `subscribeAll`
93+
},
94+
)
6495
}
6596

6697
function setUp(recordApi: MockRecordApi<Data>) {

0 commit comments

Comments
 (0)