Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

Commit 601dfaf

Browse files
committed
feat: add unit tests
1 parent efee637 commit 601dfaf

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

test/unit/directories.test.ts

+21-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import fsExtra from "fs-extra";
33
import path from "path";
44
import tempy from "tempy";
55

6-
import { isDirectoryEmpty } from "../../src/helpers/directories";
6+
import { isDirectoryEmpty, isDirectoryWriteable } from "../../src/helpers/directories";
77

88
// This has to be in sync with the valid files defined "helpers/directories".
99
const filesDirsTable: string[][] = [
@@ -105,6 +105,26 @@ describe("directories", function () {
105105
});
106106
});
107107

108+
describe("when the directory is not writable", function () {
109+
beforeEach(async function () {
110+
await fsExtra.chmod(testDirPath, 0o444);
111+
});
112+
113+
test("returns false", async function () {
114+
await expect(isDirectoryWriteable(testDirPath)).resolves.toBe(false);
115+
});
116+
});
117+
118+
describe("when the directory is writable", function () {
119+
beforeEach(async function () {
120+
await fsExtra.chmod(testDirPath, 0o777);
121+
});
122+
123+
test("returns true", async function () {
124+
await expect(isDirectoryWriteable(testDirPath)).resolves.toBe(true);
125+
});
126+
});
127+
108128
afterEach(function () {
109129
fsExtra.removeSync(testDirPath);
110130
});

0 commit comments

Comments
 (0)