Skip to content

Commit

Permalink
fix: isSameAsFile function
Browse files Browse the repository at this point in the history
  • Loading branch information
asadali214 committed Jul 12, 2024
1 parent 7f9683a commit 02a39ae
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 1 addition & 2 deletions packages/test-helper/src/testHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@ export async function createReadableStreamFromUrl(url: string) {
* @returns Promise resolving to true if input matches file contents, otherwise false.
*/
export async function isSameAsFile(
filename: string,
fileStream: NodeJS.ReadableStream,
input: NodeJS.ReadableStream | Blob | undefined
): Promise<boolean> {
try {
const fileStream = await createReadableStreamFromUrl(filename);
let fileBuffer: Buffer | ArrayBuffer;

if (typeof input === 'undefined') {
Expand Down
10 changes: 8 additions & 2 deletions packages/test-helper/test/testHelper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,10 @@ describe('isSameAsFile', () => {
type: 'text/plain;charset=utf-8',
});

const isSame = await isSameAsFile(filename, blob);
const isSame = await isSameAsFile(
await createReadableStreamFromUrl(filename),
blob
);

expect(isSame).toBe(false);
});
Expand All @@ -291,7 +294,10 @@ describe('isSameAsFile', () => {
const filename =
'https://raw.githubusercontent.com/apimatic/apimatic-js-runtime/master/packages/core/test/dummy_file.txt';

const isSame = await isSameAsFile(filename, undefined);
const isSame = await isSameAsFile(
await createReadableStreamFromUrl(filename),
undefined
);

expect(isSame).toBe(false);
});
Expand Down

0 comments on commit 02a39ae

Please sign in to comment.