diff --git a/test/unit/node/util.test.ts b/test/unit/node/util.test.ts index 30cd4672c..e765be6cf 100644 --- a/test/unit/node/util.test.ts +++ b/test/unit/node/util.test.ts @@ -1,6 +1,9 @@ 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) + }) +})