✨ (path) create a resolve path service to manage …
resolve path like ../..
This commit is contained in:
37
tests/unit/modules/repo/services/resolvePath.spec.ts
Normal file
37
tests/unit/modules/repo/services/resolvePath.spec.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { resolvePath } from '@/modules/repo/services/resolvePath'
|
||||
|
||||
describe('resolve path service', () => {
|
||||
it('set the absolute path if path to resolve is empty', () => {
|
||||
expect(resolvePath('standard/README.md', '')).toEqual('standard/')
|
||||
})
|
||||
|
||||
it('returns the path sanitized if there is no absolute path', () => {
|
||||
expect(resolvePath('', './here/note.md')).toEqual('here/note.md')
|
||||
})
|
||||
|
||||
it('set the absolute path from the current path', () => {
|
||||
expect(resolvePath('standard/README.md', './other-note.md')).toEqual(
|
||||
'standard/other-note.md'
|
||||
)
|
||||
})
|
||||
|
||||
it('set the absolute path from the current path with multiple level', () => {
|
||||
expect(
|
||||
resolvePath('standard/you/are/here/README.md', './other-note.md')
|
||||
).toEqual('standard/you/are/here/other-note.md')
|
||||
})
|
||||
|
||||
it('set the absolute path from the current path with a go back in the relative path', () => {
|
||||
expect(
|
||||
resolvePath('standard/you/are/here/README.md', '../other-note.md')
|
||||
).toEqual('standard/you/are/other-note.md')
|
||||
|
||||
expect(
|
||||
resolvePath('standard/you/are/here/README.md', '../../other-note.md')
|
||||
).toEqual('standard/you/other-note.md')
|
||||
|
||||
expect(
|
||||
resolvePath('standard/you/are/here/README.md', './../../other-note.md')
|
||||
).toEqual('standard/you/other-note.md')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user