Skip to content

Commit

Permalink
Add test for filter to verify newly included formats
Browse files Browse the repository at this point in the history
  • Loading branch information
brookewp committed Oct 6, 2023
1 parent e4282ab commit 3400e7b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/url/src/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,21 @@ describe( 'getFilename', () => {
expect( getFilename( 'image.jpg' ) ).toBe( 'image.jpg' );
} );

it( 'returns the filename for a variety of formats', () => {
expect( getFilename( 'https://wordpress.org/file.pdf' ) ).toBe(
'file.pdf'
);
expect(
getFilename( 'https://wordpress.org/image.webp?query=test' )
).toBe( 'image.webp' );
expect( getFilename( 'https://wordpress.org/video.mov#anchor' ) ).toBe(
'video.mov'
);
expect(
getFilename( 'http://localhost:8080/a/path/to/audio.mp3' )
).toBe( 'audio.mp3' );
} );

it( 'returns undefined when the provided value does not contain a filename', () => {
expect( getFilename( 'http://localhost:8080/' ) ).toBe( undefined );
expect( getFilename( 'http://localhost:8080/a/path/' ) ).toBe(
Expand Down

0 comments on commit 3400e7b

Please sign in to comment.