Merge branch 'main' of github.com:jcalixte/lite-note

This commit is contained in:
Julien Calixte
2023-08-13 21:07:24 +02:00
27 changed files with 1377 additions and 970 deletions

View File

@@ -0,0 +1,42 @@
import { describe, expect, it } from 'vitest'
import { resolvePath } from './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')
expect(
resolvePath('standard/you/are/here/README.md', './../../../other-note.md')
).toEqual('standard/other-note.md')
})
})