urlJoin.test.js 930 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { urlJoin } from '../src/utilities/urlJoin.js';
  2. describe( 'urlJoin', () => {
  3. it( 'should behave like path.join if no protocol is present', () => {
  4. expect(
  5. urlJoin( 'path', 'to', 'file.json' )
  6. ).toBe( 'path/to/file.json' );
  7. expect(
  8. urlJoin( 'path//', 'to/other/', 'file.json' )
  9. ).toBe( 'path/to/other/file.json' );
  10. } );
  11. it( 'should handle protocols correctly.', () => {
  12. expect(
  13. urlJoin( 'http://path', 'to', 'file.json' )
  14. ).toBe( 'http://path/to/file.json' );
  15. expect(
  16. urlJoin( 'http://path', 'http://path2', 'to', 'file.json' )
  17. ).toBe( 'http://path2/to/file.json' );
  18. expect(
  19. urlJoin( 'https://path', 'to', 'file.json' )
  20. ).toBe( 'https://path/to/file.json' );
  21. expect(
  22. urlJoin( 'ftp://path', 'to', 'file.json' )
  23. ).toBe( 'ftp://path/to/file.json' );
  24. expect(
  25. urlJoin( 'ftp://http://path', 'to', 'file.json' )
  26. ).toBe( 'ftp://http:/path/to/file.json' );
  27. } );
  28. } );