Skip to content

Commit

Permalink
fix(internal): clean up undefined File test (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Mar 4, 2025
1 parent 2bc2cb6 commit 313a6f7
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions tests/uploads.test.ts
Original file line number Diff line number Diff line change
@@ -14,12 +14,6 @@ function mockResponse({ url, content }: { url: string; content?: Blob }): Respon
};
}

beforeEach(() => {
// The file shim captures the global File object when it's first imported.
// Reset modules before each test so we can test the error thrown when it's undefined.
jest.resetModules();
});

describe('toFile', () => {
it('throws a helpful error for mismatched types', async () => {
await expect(
@@ -80,11 +74,23 @@ describe('toFile', () => {
});

describe('missing File error message', () => {
let prevFile: unknown;
beforeEach(() => {
// The file shim captures the global File object when it's first imported.
// Reset modules before each test so we can test the error thrown when it's undefined.
jest.resetModules();
// @ts-ignore
prevFile = globalThis.File;
// @ts-ignore
globalThis.File = undefined;
require('node:buffer').File = undefined;
});
afterEach(() => {
// Clean up
// @ts-ignore
globalThis.File = prevFile;
jest.resetModules();
});

test('is thrown', async () => {
const uploads = await import('lightswitch-api/uploads');

0 comments on commit 313a6f7

Please sign in to comment.