Files
adnify/tests/renderer/services/electronAPI.readIntent.test.ts
adnaan d8beb86fa8 refactor: replace api.file.read with api.file.readFull for complete file content retrieval
- Updated multiple components and services to use `api.file.readFull` instead of `api.file.read` to ensure full file content is read, preventing issues with truncated data.
- Adjusted related tests to mock `readFull` instead of `read`, ensuring consistency in testing file reading behavior.
- Enhanced file handling in the workspace and editor services to maintain proper content state and lifecycle management.
2026-08-26 11:13:58 +08:00

22 lines
816 B
TypeScript

import { afterEach, describe, expect, it, vi } from 'vitest'
describe('electronAPI file read intent', () => {
afterEach(() => {
vi.unstubAllGlobals()
vi.resetModules()
})
it('keeps bounded preview reads separate from full-buffer reads', async () => {
const readFile = vi.fn().mockResolvedValue('content')
vi.stubGlobal('window', { electronAPI: { readFile } })
const { api } = await import('@/renderer/services/electronAPI')
await api.file.readPreview('E:/workspace/large.txt', 'utf-8')
await api.file.readFull('E:/workspace/large.txt', 'utf-8')
expect(readFile).toHaveBeenNthCalledWith(1, 'E:/workspace/large.txt', 'utf-8')
expect(readFile).toHaveBeenNthCalledWith(2, 'E:/workspace/large.txt', 'utf-8', { full: true })
expect('read' in api.file).toBe(false)
})
})