Archived
1
0

feat(testing): refactor humanPath and add tests (#4511)

* feat: add test for humanPath

* refactor: make humanPath pure and pass in homedir
This commit is contained in:
Joe Previte
2021-11-15 19:40:34 +00:00
committed by GitHub
parent 16a5f2e171
commit 0a072f7532
5 changed files with 31 additions and 12 deletions

View File

@ -476,3 +476,19 @@ describe("isFile", () => {
expect(await util.isFile(pathToFile)).toBe(true)
})
})
describe("humanPath", () => {
it("should return an empty string if no path provided", () => {
const mockHomedir = "/home/coder"
const actual = util.humanPath(mockHomedir)
const expected = ""
expect(actual).toBe(expected)
})
it("should replace the homedir with ~", () => {
const mockHomedir = "/home/coder"
const path = `${mockHomedir}/code-server`
const actual = util.humanPath(mockHomedir, path)
const expected = "~/code-server"
expect(actual).toBe(expected)
})
})