path-utils.test.js 767 B

1234567891011121314151617181920212223242526
  1. import * as pathUtils from '~/utils/path-utils';
  2. describe('page-utils', () => {
  3. describe('.normalizePath', () => {
  4. test('should return the root path with empty string', () => {
  5. expect(pathUtils.normalizePath('')).toBe('/');
  6. });
  7. test('should return the root path as is', () => {
  8. expect(pathUtils.normalizePath('/')).toBe('/');
  9. });
  10. test('should add heading slash', () => {
  11. expect(pathUtils.normalizePath('hoge/fuga')).toBe('/hoge/fuga');
  12. });
  13. test('should remove trailing slash', () => {
  14. expect(pathUtils.normalizePath('/hoge/fuga/')).toBe('/hoge/fuga');
  15. });
  16. test('should remove unnecessary slashes', () => {
  17. expect(pathUtils.normalizePath('//hoge/fuga//')).toBe('/hoge/fuga');
  18. });
  19. });
  20. });