|
@@ -3,9 +3,10 @@ import { getUrlExtension } from '../src/utilities/urlExtension.js';
|
|
|
describe( 'getUrlExtension', () => {
|
|
|
|
|
|
it.each( [
|
|
|
- 'https://nasa.gov/foo/bar/baz.qux/tileset.json',
|
|
|
- 'https://nasa.gov/foo/bar/baz.qux/tileset.json?foo=bar',
|
|
|
- 'https://nasa.gov/foo/bar/baz.qux/tileset.json?a.b=c.d',
|
|
|
+ 'https://nasa.gov/foo/bar.baz/tileset.json',
|
|
|
+ 'https://nasa.gov/foo/bar.baz/tileset.json?foo=bar',
|
|
|
+ 'https://nasa.gov/foo/bar.baz/tileset.json?a.b=c.d',
|
|
|
+ 'https://nasa.gov/foo/bar.baz/tileset.json?a.b=c.d#e.f',
|
|
|
'https://nasa.gov/tileset.json',
|
|
|
'https://nasa.gov//tileset.json',
|
|
|
'file:///Users/JaneScientist/code/3DTilesRendererJS/example/b3dmExample.json',
|
|
@@ -14,7 +15,8 @@ describe( 'getUrlExtension', () => {
|
|
|
'foo.json?a=b',
|
|
|
'/foo.json',
|
|
|
'/foo/bar.json',
|
|
|
- ] )( 'parses the json extension out of %s', url => {
|
|
|
+ 'png.svg.json'
|
|
|
+ ] )( 'parses extensions (%s)', url => {
|
|
|
|
|
|
expect( getUrlExtension( url ) ).toBe( 'json' );
|
|
|
|
|
@@ -24,12 +26,16 @@ describe( 'getUrlExtension', () => {
|
|
|
'https://nasa.gov',
|
|
|
'https://nasa.gov/',
|
|
|
'https://nasa.gov/tileset',
|
|
|
- 'https://nasa.gov/foo/bar/baz.qux/tileset?foo=bar',
|
|
|
- 'https://nasa.gov/foo/bar/baz.qux/tileset?a.b=c.d',
|
|
|
+ 'https://nasa.gov/foo/bar.baz/tileset?foo=bar',
|
|
|
+ 'https://nasa.gov/foo/bar.baz/tileset?a.b=c.d',
|
|
|
'https://nasa.gov/tileset',
|
|
|
'https://nasa.gov/tileset.',
|
|
|
'Pleiades',
|
|
|
- ] )( 'returns null for strings that are not URLs with extensions %s', url => {
|
|
|
+ '.',
|
|
|
+ '..',
|
|
|
+ '',
|
|
|
+ undefined,
|
|
|
+ ] )( 'returns null for values that are not URLs with extensions (%s)', url => {
|
|
|
|
|
|
expect( getUrlExtension( url ) ).toBeNull();
|
|
|
|