import { server } from './server.js'
import { type FormContextRequest } from '../../types.js'
import { type FormRequest } from '../../../../routes/types.js'

const mockYar = {
  flash: jest.fn().mockReturnValue([]),
  clear: jest.fn(),
  get: jest.fn(),
  set: jest.fn(),
  reset: jest.fn()
}

export function buildFormRequest(
  request: Omit<FormRequest, 'server' | 'yar'>
): FormRequest {
  return {
    ...request,
    yar: mockYar,
    server
  } as unknown as FormRequest
}

export function buildFormContextRequest(
  request: Omit<FormContextRequest, 'server' | 'yar'>
): FormContextRequest {
  return {
    ...request,
    yar: mockYar,
    server
  } as unknown as FormContextRequest
}
