Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

911 B
Raw Blame
// FE-MAILINGEST-API-001
import { describe, expect, it, vi } from 'vitest';

vi.mock('./client', () => ({
  default: { get: vi.fn(), post: vi.fn(), patch: vi.fn(), put: vi.fn(), delete: vi.fn() },
  postMultipart: vi.fn(async () => ({ duplicate: false })),
}));

import apiClient, { postMultipart } from './client';
import { mailIngestApi } from './mailIngest';

describe('mailIngestApi.upload', () => {
  it('FE-MAILINGEST-API-001: sends the .eml as a multipart form, never through the JSON post', async () => {
    const file = new File(['From: [email protected]\r\n\r\nhi'], 'booking.eml', { type: 'message/rfc822' });
    expect(await mailIngestApi.upload(file)).toEqual({ duplicate: false });
    const [url, form] = vi.mocked(postMultipart).mock.calls[0];
    expect(url).toBe('/mail-ingest/upload');
    expect((form as FormData).get('file')).toBe(file);
    expect(apiClient.post).not.toHaveBeenCalled();
  });
});