path-utils.test.js 852 B

1234567891011121314151617181920212223242526272829303132
  1. const chai = require('chai');
  2. const sinonChai = require('sinon-chai');
  3. const expect = chai.expect;
  4. chai.use(sinonChai);
  5. const pathUtils = require('@commons/util/path-utils');
  6. describe('page-utils', () => {
  7. describe('.normalizePath', () => {
  8. it('should rurn root path with empty string', (done) => {
  9. expect(pathUtils.normalizePath('')).to.equal('/');
  10. done();
  11. });
  12. it('should add heading slash', (done) => {
  13. expect(pathUtils.normalizePath('hoge/fuga')).to.equal('/hoge/fuga');
  14. done();
  15. });
  16. it('should remove trailing slash', (done) => {
  17. expect(pathUtils.normalizePath('/hoge/fuga/')).to.equal('/hoge/fuga');
  18. done();
  19. });
  20. it('should remove unnecessary slashes', (done) => {
  21. expect(pathUtils.normalizePath('//hoge/fuga//')).to.equal('/hoge/fuga');
  22. done();
  23. });
  24. });
  25. });