Skip to content

Commit b99706f

Browse files
committed
chore: add unit tests for toPathComponents util fn
1 parent 8c1b389 commit b99706f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* eslint-env mocha */
2+
3+
import { expect } from 'aegir/utils/chai.js'
4+
import toPathComponents from '../src/utils/to-path-components.js'
5+
6+
describe('toPathComponents', () => {
7+
it('splits on unescaped "/" characters', () => {
8+
const path = 'foo/bar/baz'
9+
const components = toPathComponents(path)
10+
expect(components.length).to.eq(3)
11+
})
12+
13+
it('does not split on escaped "/" characters', () => {
14+
const path = 'foo\\/bar/baz'
15+
const components = toPathComponents(path)
16+
expect(components.length).to.eq(2)
17+
})
18+
19+
// see https://github.com/ipfs/js-ipfs-unixfs/issues/177 for context
20+
it('does not split on "^" characters', () => {
21+
const path = 'foo/bar^baz^^qux'
22+
const components = toPathComponents(path)
23+
expect(components.length).to.eq(2)
24+
})
25+
})

0 commit comments

Comments
 (0)