Skip to content

Commit

Permalink
chore: change extension of blob test files to .ts
Browse files Browse the repository at this point in the history
  • Loading branch information
jpstevens committed May 9, 2024
1 parent ae1dd64 commit 6c81e6a
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Internal dependencies
*/
import { isBlobURL, getBlobTypeByURL, downloadBlob } from '../';
import { isBlobURL, getBlobTypeByURL, downloadBlob } from '..';

describe( 'isBlobURL', () => {
it( 'returns true if the url starts with "blob:"', () => {
Expand All @@ -13,6 +13,8 @@ describe( 'isBlobURL', () => {
} );

it( 'returns false if the url is not defined', () => {
// calling isBlobURL without a URL is not type compliant, so ignore it
// @ts-ignore
expect( isBlobURL() ).toBe( false );
} );
} );
Expand All @@ -23,6 +25,8 @@ describe( 'getBlobTypeByURL', () => {
} );

it( 'returns undefined if the url is not defined', () => {
// calling getBlobTypeByURL without a URL is not type compliant, so ignore it
// @ts-ignore
expect( getBlobTypeByURL() ).toBe( undefined );
} );
} );
Expand All @@ -36,17 +40,18 @@ describe( 'downloadBlob', () => {
const createElementSpy = jest
.spyOn( global.document, 'createElement' )
.mockReturnValue( mockAnchorElement );

const mockBlob = jest.fn();
const blobSpy = jest.spyOn( window, 'Blob' ).mockReturnValue( mockBlob );
const blobSpy = jest
.spyOn( window, 'Blob' )
.mockReturnValue( mockBlob as unknown as Blob );
jest.spyOn( document.body, 'appendChild' );
jest.spyOn( document.body, 'removeChild' );
beforeEach( () => {
// Can't seem to spy on these static methods. They are `undefined`.
// Possibly overwritten: https://github.com/WordPress/gutenberg/blob/trunk/packages/jest-preset-default/scripts/setup-globals.js#L5
window.URL = {
createObjectURL,
revokeObjectURL,
};
window.URL.createObjectURL = createObjectURL;
window.URL.revokeObjectURL = revokeObjectURL;
} );

afterAll( () => {
Expand Down

0 comments on commit 6c81e6a

Please sign in to comment.