import path from 'node:path'
import { afterEach, describe, expect, it, vi } from 'vitest'

import { getProjectDataDir } from './project-data-dir'

describe('getProjectDataDir', () => {
	afterEach(() => {
		vi.restoreAllMocks()
	})

	it('resolves runtime data paths from the cwd where bosun was launched', () => {
		vi.spyOn(process, 'cwd').mockReturnValue('/tmp/example-project')

		expect(getProjectDataDir()).toBe(path.resolve('/tmp/example-project', 'data'))
		expect(getProjectDataDir('history', 'agent.json')).toBe(
			path.resolve('/tmp/example-project', 'data', 'history', 'agent.json')
		)
	})
})
