2
0

path-utils.test.js 804 B

12345678910111213141516171819202122232425262728
  1. require('module-alias/register');
  2. const pathUtils = require('@src/util/path-utils');
  3. describe('page-utils', () => {
  4. describe('.normalizePath', () => {
  5. test('should return the root path with empty string', () => {
  6. expect(pathUtils.normalizePath('')).toBe('/');
  7. });
  8. test('should return the root path as is', () => {
  9. expect(pathUtils.normalizePath('/')).toBe('/');
  10. });
  11. test('should add heading slash', () => {
  12. expect(pathUtils.normalizePath('hoge/fuga')).toBe('/hoge/fuga');
  13. });
  14. test('should remove trailing slash', () => {
  15. expect(pathUtils.normalizePath('/hoge/fuga/')).toBe('/hoge/fuga');
  16. });
  17. test('should remove unnecessary slashes', () => {
  18. expect(pathUtils.normalizePath('//hoge/fuga//')).toBe('/hoge/fuga');
  19. });
  20. });
  21. });