Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Dam-Buty committed Jul 17, 2024
1 parent 235b65d commit ceca78c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions tests/attachments.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ const client = new LiteralClient(apiKey, url);
const filePath = './tests/chainlit-logo.png';
const mime = 'image/png';

function removeVariableParts(url: string) {
return url.split('X-Amz-Date')[0].split('X-Goog-Date')[0];
}

describe('Attachments', () => {
describe('Uploading a file', () => {
const stream = createReadStream(filePath);
Expand Down Expand Up @@ -47,9 +51,10 @@ describe('Attachments', () => {

const fetchedStep = await client.api.getStep(step.id!);

const urlWithoutAmzVariables = attachment.url!.split('X-Amz-Date')[0];
const fetchedUrlWithoutAmzVariables =
fetchedStep?.attachments![0].url!.split('X-Amz-Date')[0];
const urlWithoutVariables = removeVariableParts(attachment.url!);
const fetchedUrlWithoutVariables = removeVariableParts(
fetchedStep?.attachments![0].url as string
);

expect(fetchedStep?.attachments?.length).toBe(1);
expect(fetchedStep?.attachments![0].objectKey).toEqual(
Expand All @@ -59,7 +64,7 @@ describe('Attachments', () => {
expect(fetchedStep?.attachments![0].metadata).toEqual(
attachment.metadata
);
expect(urlWithoutAmzVariables).toEqual(fetchedUrlWithoutAmzVariables);
expect(urlWithoutVariables).toEqual(fetchedUrlWithoutVariables);
});
});

Expand Down

0 comments on commit ceca78c

Please sign in to comment.