Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianWhitneyAI committed Nov 11, 2024
1 parent 52bd1a9 commit 3e9a0eb
Showing 1 changed file with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,25 +78,38 @@ describe("HttpFileService", () => {
});
});

describe("getCountOfMatchingFiles", () => {
describe("cacheFiles", () => {
const httpClient = createMockHttpClient({
when: `${baseUrl}/${HttpFileService.BASE_FILE_COUNT_URL}`,
when: `${baseUrl}/${HttpFileService.BASE_FILE_CACHE_URL}`,
respondWith: {
data: {
data: [2],
cacheFileStatuses: {
abc123: "DOWNLOAD_COMPLETE",
def456: "ERROR",
},
},
},
});

it("issues request for count of files matching given parameters", async () => {
it("sends file IDs to be cached and returns their statuses", async () => {
// Arrange
const fileService = new HttpFileService({
baseUrl,
httpClient,
downloadService: new FileDownloadServiceNoop(),
});
const fileSet = new FileSet();
const count = await fileService.getCountOfMatchingFiles(fileSet);
expect(count).to.equal(2);
const fileIds = ["abc123", "def456"];

// Act
const response = await fileService.cacheFiles(fileIds);

// Assert
expect(response).to.deep.equal({
cacheFileStatuses: {
abc123: "DOWNLOAD_COMPLETE",
def456: "ERROR",
},
});
});
});
});

0 comments on commit 3e9a0eb

Please sign in to comment.