File size: 869 Bytes
b59aa07
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { describe, expect, it } from "vitest";
import { FileService } from "#/api/file-service/file-service.api";
import {
  FILE_VARIANTS_1,
  FILE_VARIANTS_2,
} from "#/mocks/file-service-handlers";

/**
 * File service API tests. The actual API calls are mocked using MSW.
 * You can find the mock handlers in `frontend/src/mocks/file-service-handlers.ts`.
 */

describe("FileService", () => {
  it("should get a list of files", async () => {
    await expect(FileService.getFiles("test-conversation-id")).resolves.toEqual(
      FILE_VARIANTS_1,
    );

    await expect(
      FileService.getFiles("test-conversation-id-2"),
    ).resolves.toEqual(FILE_VARIANTS_2);
  });

  it("should get content of a file", async () => {
    await expect(
      FileService.getFile("test-conversation-id", "file1.txt"),
    ).resolves.toEqual("Content of file1.txt");
  });
});