未验证 提交 6e33dccb 编写于 作者: J Joe Previte

feat: add tests for isFile

上级 5c613185
import * as cp from "child_process"
import * as path from "path"
import { promises as fs } from "fs"
import { generateUuid } from "../../../src/common/util"
import * as util from "../../../src/node/util"
import { tmpdir } from "../../../src/node/constants"
describe("getEnvPaths", () => {
describe("on darwin", () => {
......@@ -464,9 +467,6 @@ describe("pathToFsPath", () => {
it("should keep drive letter casing when set to true", () => {
expect(util.pathToFsPath("/C:/far/bo", true)).toBe("C:/far/bo")
})
it("should use the first string in a string array", () => {
expect(util.pathToFsPath("/hello/foo")).toBe("/hello/foo")
})
it("should replace / with \\ on Windows", () => {
let ORIGINAL_PLATFORM = process.platform
......@@ -481,3 +481,23 @@ describe("pathToFsPath", () => {
})
})
})
describe("isFile", () => {
const testDir = path.join(tmpdir, "tests", "isFile")
let pathToFile = ""
beforeEach(async () => {
pathToFile = path.join(testDir, "foo.txt")
await fs.mkdir(testDir, { recursive: true })
await fs.writeFile(pathToFile, "hello")
})
afterEach(async () => {
await fs.rm(testDir, { recursive: true, force: true })
})
it("should return false if the path doesn't exist", async () => {
expect(await util.isFile(testDir)).toBe(false)
})
it("should return true if is file", async () => {
expect(await util.isFile(pathToFile)).toBe(true)
})
})
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册