Skip to content

Commit e389708

Browse files
test: lstat
2 parents 570337b + 8cd51e7 commit e389708

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

test/SyncAsyncFileSystemDecorator.test.js

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const fs = require("fs");
44
const path = require("path");
55
const SyncAsyncFileSystemDecorator = require("../lib/SyncAsyncFileSystemDecorator");
66

7-
describe("SyncAsyncFileSystemDecorator stat", function () {
7+
describe("SyncAsyncFileSystemDecorator stat", function () {
88
it("should use options when they're provided", function (done) {
99
const decoratedFs = new SyncAsyncFileSystemDecorator(fs);
1010
decoratedFs.stat(
@@ -38,3 +38,42 @@ describe("SyncAsyncFileSystemDecorator stat", function () {
3838
);
3939
});
4040
});
41+
42+
describe("SyncAsyncFileSystemDecorator lstat", function () {
43+
it("should use options when they're provided", function (done) {
44+
const decoratedFs = new SyncAsyncFileSystemDecorator(fs);
45+
if (decoratedFs.lstat) {
46+
decoratedFs.lstat(
47+
path.join(__dirname, "fixtures", "decorated-fs", "exists.js"),
48+
{ bigint: true },
49+
function (error, result) {
50+
expect(error).toBeNull();
51+
expect(result).toHaveProperty("size");
52+
expect(result).toHaveProperty("birthtime");
53+
expect(
54+
typeof (/** @type {import("fs").BigIntStats} */ (result).size)
55+
).toEqual("bigint");
56+
done();
57+
}
58+
);
59+
}
60+
});
61+
62+
it("should work correctly when no options provided", function (done) {
63+
const decoratedFs = new SyncAsyncFileSystemDecorator(fs);
64+
if (decoratedFs.lstat) {
65+
decoratedFs.lstat(
66+
path.join(__dirname, "fixtures", "decorated-fs", "exists.js"),
67+
function (error, result) {
68+
expect(error).toBeNull();
69+
expect(result).toHaveProperty("size");
70+
expect(result).toHaveProperty("birthtime");
71+
expect(
72+
typeof (/** @type {import("fs").Stats} */ (result).size)
73+
).toEqual("number");
74+
done();
75+
}
76+
);
77+
}
78+
});
79+
});

0 commit comments

Comments
 (0)