Skip to content

Commit 6eadf63

Browse files
committed
run lint
1 parent ee9617c commit 6eadf63

File tree

3 files changed

+71
-65
lines changed

3 files changed

+71
-65
lines changed

packages/db-collections/tests/query.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ describe(`QueryCollection`, () => {
435435
})
436436

437437
describe(`Direct persistence handlers`, () => {
438-
it(`should pass through direct persistence handlers to collection options`, async () => {
438+
it(`should pass through direct persistence handlers to collection options`, () => {
439439
const queryKey = [`directPersistenceTest`]
440440
const items = [{ id: `1`, name: `Item 1` }]
441441
const queryFn = vi.fn().mockResolvedValue(items)

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

Lines changed: 65 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -131,51 +131,53 @@ describe(`Collection getters`, () => {
131131

132132
it(`updates size correctly with optimistic inserts`, () => {
133133
const mutationFn = vi.fn().mockResolvedValue(undefined)
134-
134+
135135
expect(collection.size).toBe(2)
136-
136+
137137
const tx = createTransaction({ mutationFn })
138138
tx.mutate(() => collection.insert({ id: `item3`, name: `Item 3` }))
139-
139+
140140
expect(collection.size).toBe(3)
141141
})
142142

143143
it(`updates size correctly with optimistic updates (should not change size)`, () => {
144144
const mutationFn = vi.fn().mockResolvedValue(undefined)
145-
145+
146146
expect(collection.size).toBe(2)
147-
147+
148148
const tx = createTransaction({ mutationFn })
149-
tx.mutate(() => collection.update(`item1`, (draft) => {
150-
draft.name = `Updated Item 1`
151-
}))
152-
149+
tx.mutate(() =>
150+
collection.update(`item1`, (draft) => {
151+
draft.name = `Updated Item 1`
152+
})
153+
)
154+
153155
expect(collection.size).toBe(2) // Size should remain the same for updates
154156
})
155157

156158
it(`updates size correctly with optimistic deletes`, () => {
157159
const mutationFn = vi.fn().mockResolvedValue(undefined)
158-
160+
159161
expect(collection.size).toBe(2)
160-
162+
161163
const tx = createTransaction({ mutationFn })
162164
tx.mutate(() => collection.delete(`item1`))
163-
165+
164166
expect(collection.size).toBe(1)
165167
})
166168

167169
it(`updates size correctly with multiple optimistic operations`, () => {
168170
const mutationFn = vi.fn().mockResolvedValue(undefined)
169-
171+
170172
expect(collection.size).toBe(2)
171-
173+
172174
const tx = createTransaction({ mutationFn })
173175
tx.mutate(() => {
174176
collection.insert({ id: `item3`, name: `Item 3` })
175177
collection.insert({ id: `item4`, name: `Item 4` })
176178
collection.delete(`item1`)
177179
})
178-
180+
179181
expect(collection.size).toBe(3) // 2 original - 1 deleted + 2 inserted = 3
180182
})
181183
})
@@ -193,32 +195,34 @@ describe(`Collection getters`, () => {
193195

194196
it(`returns true for optimistically inserted items`, () => {
195197
const mutationFn = vi.fn().mockResolvedValue(undefined)
196-
198+
197199
const tx = createTransaction({ mutationFn })
198200
tx.mutate(() => collection.insert({ id: `item3`, name: `Item 3` }))
199-
201+
200202
const key = `KEY::${collection.id}/item3`
201203
expect(collection.has(key)).toBe(true)
202204
})
203205

204206
it(`returns false for optimistically deleted items`, () => {
205207
const mutationFn = vi.fn().mockResolvedValue(undefined)
206-
208+
207209
const tx = createTransaction({ mutationFn })
208210
tx.mutate(() => collection.delete(`item1`))
209-
211+
210212
const key = `KEY::${collection.id}/item1`
211213
expect(collection.has(key)).toBe(false)
212214
})
213215

214216
it(`returns true for optimistically updated items`, () => {
215217
const mutationFn = vi.fn().mockResolvedValue(undefined)
216-
218+
217219
const tx = createTransaction({ mutationFn })
218-
tx.mutate(() => collection.update(`item1`, (draft) => {
219-
draft.name = `Updated Item 1`
220-
}))
221-
220+
tx.mutate(() =>
221+
collection.update(`item1`, (draft) => {
222+
draft.name = `Updated Item 1`
223+
})
224+
)
225+
222226
const key = `KEY::${collection.id}/item1`
223227
expect(collection.has(key)).toBe(true)
224228
})
@@ -234,10 +238,10 @@ describe(`Collection getters`, () => {
234238

235239
it(`excludes optimistically deleted items`, () => {
236240
const mutationFn = vi.fn().mockResolvedValue(undefined)
237-
241+
238242
const tx = createTransaction({ mutationFn })
239243
tx.mutate(() => collection.delete(`item1`))
240-
244+
241245
const keys = Array.from(collection.keys())
242246
expect(keys).toHaveLength(1)
243247
expect(keys).toContain(`KEY::${collection.id}/item2`)
@@ -246,10 +250,10 @@ describe(`Collection getters`, () => {
246250

247251
it(`includes optimistically inserted items`, () => {
248252
const mutationFn = vi.fn().mockResolvedValue(undefined)
249-
253+
250254
const tx = createTransaction({ mutationFn })
251255
tx.mutate(() => collection.insert({ id: `item3`, name: `Item 3` }))
252-
256+
253257
const keys = Array.from(collection.keys())
254258
expect(keys).toHaveLength(3)
255259
expect(keys).toContain(`KEY::${collection.id}/item1`)
@@ -268,10 +272,10 @@ describe(`Collection getters`, () => {
268272

269273
it(`excludes optimistically deleted items`, () => {
270274
const mutationFn = vi.fn().mockResolvedValue(undefined)
271-
275+
272276
const tx = createTransaction({ mutationFn })
273277
tx.mutate(() => collection.delete(`item1`))
274-
278+
275279
const values = Array.from(collection.values())
276280
expect(values).toHaveLength(1)
277281
expect(values).toContainEqual({ id: `item2`, name: `Item 2` })
@@ -280,10 +284,10 @@ describe(`Collection getters`, () => {
280284

281285
it(`includes optimistically inserted items`, () => {
282286
const mutationFn = vi.fn().mockResolvedValue(undefined)
283-
287+
284288
const tx = createTransaction({ mutationFn })
285289
tx.mutate(() => collection.insert({ id: `item3`, name: `Item 3` }))
286-
290+
287291
const values = Array.from(collection.values())
288292
expect(values).toHaveLength(3)
289293
expect(values).toContainEqual({ id: `item1`, name: `Item 1` })
@@ -293,12 +297,14 @@ describe(`Collection getters`, () => {
293297

294298
it(`reflects optimistic updates`, () => {
295299
const mutationFn = vi.fn().mockResolvedValue(undefined)
296-
300+
297301
const tx = createTransaction({ mutationFn })
298-
tx.mutate(() => collection.update(`item1`, (draft) => {
299-
draft.name = `Updated Item 1`
300-
}))
301-
302+
tx.mutate(() =>
303+
collection.update(`item1`, (draft) => {
304+
draft.name = `Updated Item 1`
305+
})
306+
)
307+
302308
const values = Array.from(collection.values())
303309
expect(values).toHaveLength(2)
304310
expect(values).toContainEqual({ id: `item1`, name: `Updated Item 1` })
@@ -322,10 +328,10 @@ describe(`Collection getters`, () => {
322328

323329
it(`excludes optimistically deleted items`, () => {
324330
const mutationFn = vi.fn().mockResolvedValue(undefined)
325-
331+
326332
const tx = createTransaction({ mutationFn })
327333
tx.mutate(() => collection.delete(`item1`))
328-
334+
329335
const entries = Array.from(collection.entries())
330336
expect(entries).toHaveLength(1)
331337
expect(entries).toContainEqual([
@@ -336,10 +342,10 @@ describe(`Collection getters`, () => {
336342

337343
it(`includes optimistically inserted items`, () => {
338344
const mutationFn = vi.fn().mockResolvedValue(undefined)
339-
345+
340346
const tx = createTransaction({ mutationFn })
341347
tx.mutate(() => collection.insert({ id: `item3`, name: `Item 3` }))
342-
348+
343349
const entries = Array.from(collection.entries())
344350
expect(entries).toHaveLength(3)
345351
expect(entries).toContainEqual([
@@ -358,12 +364,14 @@ describe(`Collection getters`, () => {
358364

359365
it(`reflects optimistic updates`, () => {
360366
const mutationFn = vi.fn().mockResolvedValue(undefined)
361-
367+
362368
const tx = createTransaction({ mutationFn })
363-
tx.mutate(() => collection.update(`item1`, (draft) => {
364-
draft.name = `Updated Item 1`
365-
}))
366-
369+
tx.mutate(() =>
370+
collection.update(`item1`, (draft) => {
371+
draft.name = `Updated Item 1`
372+
})
373+
)
374+
367375
const entries = Array.from(collection.entries())
368376
expect(entries).toHaveLength(2)
369377
expect(entries).toContainEqual([
@@ -392,34 +400,36 @@ describe(`Collection getters`, () => {
392400

393401
it(`returns optimistically inserted items`, () => {
394402
const mutationFn = vi.fn().mockResolvedValue(undefined)
395-
403+
396404
const tx = createTransaction({ mutationFn })
397405
tx.mutate(() => collection.insert({ id: `item3`, name: `Item 3` }))
398-
406+
399407
const key = `KEY::${collection.id}/item3`
400408
const value = collection.get(key)
401409
expect(value).toEqual({ id: `item3`, name: `Item 3` })
402410
})
403411

404412
it(`returns undefined for optimistically deleted items`, () => {
405413
const mutationFn = vi.fn().mockResolvedValue(undefined)
406-
414+
407415
const tx = createTransaction({ mutationFn })
408416
tx.mutate(() => collection.delete(`item1`))
409-
417+
410418
const key = `KEY::${collection.id}/item1`
411419
const value = collection.get(key)
412420
expect(value).toBeUndefined()
413421
})
414422

415423
it(`returns updated values for optimistically updated items`, () => {
416424
const mutationFn = vi.fn().mockResolvedValue(undefined)
417-
425+
418426
const tx = createTransaction({ mutationFn })
419-
tx.mutate(() => collection.update(`item1`, (draft) => {
420-
draft.name = `Updated Item 1`
421-
}))
422-
427+
tx.mutate(() =>
428+
collection.update(`item1`, (draft) => {
429+
draft.name = `Updated Item 1`
430+
})
431+
)
432+
423433
const key = `KEY::${collection.id}/item1`
424434
const value = collection.get(key)
425435
expect(value).toEqual({ id: `item1`, name: `Updated Item 1` })

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,16 +1085,12 @@ describe(`Query Collections`, () => {
10851085

10861086
const query = queryBuilder()
10871087
.from({ collection })
1088-
.select(({ collection }) => ({
1089-
displayName: `${collection.name} (Age: ${collection.age})`,
1090-
status: collection.isActive ? `Active` : `Inactive`,
1088+
.select(({ collection: result }) => ({
1089+
displayName: `${result.name} (Age: ${result.age})`,
1090+
status: result.isActive ? `Active` : `Inactive`,
10911091
ageGroup:
1092-
collection.age < 30
1093-
? `Young`
1094-
: collection.age < 40
1095-
? `Middle`
1096-
: `Senior`,
1097-
emailDomain: collection.email.split(`@`)[1],
1092+
result.age < 30 ? `Young` : result.age < 40 ? `Middle` : `Senior`,
1093+
emailDomain: result.email.split(`@`)[1],
10981094
}))
10991095

11001096
const compiledQuery = compileQuery(query)

0 commit comments

Comments
 (0)