exiftool-vendored
Version:
Efficient, cross-platform access to ExifTool
53 lines • 2.81 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const promises_1 = require("node:fs/promises");
const node_os_1 = require("node:os");
const node_path_1 = require("node:path");
const _chai_spec_1 = require("./_chai.spec");
const File_1 = require("./File");
const IsWin32_1 = require("./IsWin32");
describe("File", () => {
describe("isFileEmpty()", () => {
it("returns true for non-existent file", async () => {
const path = (0, _chai_spec_1.tmpname)();
(0, _chai_spec_1.expect)(await (0, File_1.isFileEmpty)(path)).to.eql(true);
});
it("returns true for empty file", async () => {
const path = (0, _chai_spec_1.tmpname)();
await (0, promises_1.writeFile)(path, "");
(0, _chai_spec_1.expect)(await (0, File_1.isFileEmpty)(path)).to.eql(true);
});
it("returns false for non-empty file", async () => {
const path = (0, _chai_spec_1.tmpname)();
await (0, promises_1.writeFile)(path, "content");
(0, _chai_spec_1.expect)(await (0, File_1.isFileEmpty)(path)).to.eql(false);
});
it("throws error for blank path", async () => {
await (0, _chai_spec_1.expect)((0, File_1.isFileEmpty)("")).to.be.rejectedWith("isFileEmpty(): blank path");
});
});
describe("compareFilePaths()", () => {
it("returns true for identical paths", () => {
const path = "/some/path/file.txt";
(0, _chai_spec_1.expect)((0, File_1.compareFilePaths)(path, path)).to.eql(true);
});
it("returns true for normalized paths", () => {
(0, _chai_spec_1.expect)((0, File_1.compareFilePaths)((0, node_path_1.join)((0, node_os_1.homedir)(), "file"), (0, node_path_1.join)((0, node_os_1.homedir)(), "dir", "..", "file"))).to.eql(true);
});
it("returns true for case-sensitive paths", () => {
(0, _chai_spec_1.expect)((0, File_1.compareFilePaths)("/path/to/file", "/path/to/file")).to.eql(true);
});
it("returns !isPlatformCaseSensitive() for case-insensitive-matching paths", () => {
(0, _chai_spec_1.expect)((0, File_1.compareFilePaths)("/PATH/TO/FILE", "/path/to/file")).to.eql(!(0, File_1.isPlatformCaseSensitive)());
});
if ((0, IsWin32_1.isWin32)()) {
it("handles different path separators on Windows", () => {
(0, _chai_spec_1.expect)((0, File_1.compareFilePaths)("/path/to/file", "\\path\\to/file")).to.eql(true);
});
}
it("returns false for different paths", () => {
(0, _chai_spec_1.expect)((0, File_1.compareFilePaths)("/path/to/file1", "/path/to/file2")).to.eql(false);
});
});
});
//# sourceMappingURL=File.spec.js.map