|
1 | 1 | import * as cp from "child_process"
|
| 2 | +import * as path from "path" |
| 3 | +import { promises as fs } from "fs" |
2 | 4 | import { generateUuid } from "../../../src/common/util"
|
3 | 5 | import * as util from "../../../src/node/util"
|
| 6 | +import { tmpdir } from "../../../src/node/constants" |
4 | 7 |
|
5 | 8 | describe("getEnvPaths", () => {
|
6 | 9 | describe("on darwin", () => {
|
@@ -481,3 +484,23 @@ describe("pathToFsPath", () => {
|
481 | 484 | })
|
482 | 485 | })
|
483 | 486 | })
|
| 487 | + |
| 488 | +describe("isFile", () => { |
| 489 | + const testDir = path.join(tmpdir, "tests", "isFile") |
| 490 | + let pathToFile = "" |
| 491 | + |
| 492 | + beforeEach(async () => { |
| 493 | + pathToFile = path.join(testDir, "foo.txt") |
| 494 | + await fs.mkdir(testDir, { recursive: true }) |
| 495 | + await fs.writeFile(pathToFile, "hello") |
| 496 | + }) |
| 497 | + afterEach(async () => { |
| 498 | + await fs.rm(testDir, { recursive: true, force: true }) |
| 499 | + }) |
| 500 | + it("should return false if the path doesn't exist", async () => { |
| 501 | + expect(await util.isFile(testDir)).toBe(false) |
| 502 | + }) |
| 503 | + it("should return true if is file", async () => { |
| 504 | + expect(await util.isFile(pathToFile)).toBe(true) |
| 505 | + }) |
| 506 | +}) |
0 commit comments