ConusAI vendor 81941888f
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
exportToS3: vi.fn(async () => 'exports/visitor-1/now.json' as string | null),
|
||||
notes: [{ id: 'n-1', title: 'Plan' }],
|
||||
}))
|
||||
|
||||
vi.mock('@/shared/api', () => ({
|
||||
db: () => ({
|
||||
select: () => ({ from: () => ({ where: () => ({ orderBy: () => ({ limit: async () => mocks.notes }) }) }) }),
|
||||
}),
|
||||
}))
|
||||
vi.mock('@/shared/lib/optional', () => ({ exportToS3: mocks.exportToS3 }))
|
||||
vi.mock('@/shared/lib/visitor-session', () => ({ ensureVisitor: async () => 'visitor-1' }))
|
||||
|
||||
import { exportNotes } from '@/features/export-notes/api/actions'
|
||||
|
||||
describe('exportNotes', () => {
|
||||
beforeEach(() => {
|
||||
mocks.exportToS3.mockClear()
|
||||
})
|
||||
|
||||
it('writes the visitor’s own notes to S3 once', async () => {
|
||||
await exportNotes()
|
||||
expect(mocks.exportToS3).toHaveBeenCalledTimes(1)
|
||||
expect(mocks.exportToS3).toHaveBeenCalledWith('visitor-1', mocks.notes)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user