Remove untildify
This commit is contained in:
@@ -3,7 +3,7 @@ const warnMock = jest.fn()
|
||||
import { FileArtifactGlobber } from "../src/ArtifactGlobber"
|
||||
import { Globber } from "../src/Globber"
|
||||
import { Artifact } from "../src/Artifact"
|
||||
import untildify = require("untildify")
|
||||
import { expandTilde } from "../src/PathExpander"
|
||||
|
||||
const contentType = "raw"
|
||||
const globMock = jest.fn()
|
||||
@@ -39,7 +39,7 @@ describe("ArtifactGlobber", () => {
|
||||
const expectedArtifacts = globResults.map((path) => new Artifact(path, contentType))
|
||||
|
||||
expect(globber.globArtifactString("~/path", "raw", false)).toEqual(expectedArtifacts)
|
||||
expect(globMock).toHaveBeenCalledWith(untildify("~/path"))
|
||||
expect(globMock).toHaveBeenCalledWith(expandTilde("~/path"))
|
||||
expect(warnMock).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
|
||||
42
__tests__/PathExpander.test.ts
Normal file
42
__tests__/PathExpander.test.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import os from "os"
|
||||
import { expandTilde } from "../src/PathExpander"
|
||||
|
||||
describe("PathExpander", () => {
|
||||
describe("expandTilde", () => {
|
||||
it("expands ~ at the start of a path", () => {
|
||||
const result = expandTilde("~/documents")
|
||||
expect(result).toBe(`${os.homedir()}/documents`)
|
||||
})
|
||||
|
||||
it("expands ~ with backslash separator", () => {
|
||||
const result = expandTilde("~\\documents")
|
||||
expect(result).toBe(`${os.homedir()}\\documents`)
|
||||
})
|
||||
|
||||
it("expands standalone ~", () => {
|
||||
const result = expandTilde("~")
|
||||
expect(result).toBe(os.homedir())
|
||||
})
|
||||
|
||||
it("does not expand ~ in the middle of a path", () => {
|
||||
const result = expandTilde("/home/~user/documents")
|
||||
expect(result).toBe("/home/~user/documents")
|
||||
})
|
||||
|
||||
it("does not expand ~username patterns", () => {
|
||||
const result = expandTilde("~username/documents")
|
||||
expect(result).toBe("~username/documents")
|
||||
})
|
||||
|
||||
it("returns path unchanged when no tilde present", () => {
|
||||
const result = expandTilde("/absolute/path")
|
||||
expect(result).toBe("/absolute/path")
|
||||
})
|
||||
|
||||
it("returns relative path unchanged", () => {
|
||||
const result = expandTilde("relative/path")
|
||||
expect(result).toBe("relative/path")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user