path-utils.spec.ts 816 B

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