import { describe, it, expect, vi } from 'vitest';
import { executeLogs } from '../../../main/commands/logs.command.js';
function createFakeReadLogsDeps(overrides) {
    return {
        logFileExists: vi.fn(() => false),
        readLastLines: vi.fn(() => []),
        watchFile: vi.fn(() => ({ stop: vi.fn() })),
        ...overrides,
    };
}
function createFakeDeps(overrides) {
    return {
        readLogsDeps: createFakeReadLogsDeps(),
        log: vi.fn(),
        error: vi.fn(),
        exit: vi.fn(),
        ...overrides,
    };
}
describe('executeLogs', () => {
    it('should exit(1) when no log file exists', () => {
        const deps = createFakeDeps();
        executeLogs(false, 20, deps);
        expect(deps.error).toHaveBeenCalled();
        expect(deps.exit).toHaveBeenCalledWith(1);
    });
    it('should output log lines when file exists', () => {
        const deps = createFakeDeps({
            readLogsDeps: createFakeReadLogsDeps({
                logFileExists: vi.fn(() => true),
                readLastLines: vi.fn(() => ['line 1', 'line 2']),
            }),
        });
        executeLogs(false, 20, deps);
        expect(deps.log).toHaveBeenCalledWith('line 1');
        expect(deps.log).toHaveBeenCalledWith('line 2');
    });
    it('should output initial lines and set up watcher in follow mode', () => {
        const stopFn = vi.fn();
        const deps = createFakeDeps({
            readLogsDeps: createFakeReadLogsDeps({
                logFileExists: vi.fn(() => true),
                readLastLines: vi.fn(() => ['initial']),
                watchFile: vi.fn(() => ({ stop: stopFn })),
            }),
        });
        executeLogs(true, 10, deps);
        expect(deps.log).toHaveBeenCalledWith('initial');
    });
});
//# sourceMappingURL=executeLogs.test.js.map