Skip to content

Commit

Permalink
test: lstat
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait authored May 29, 2024
2 parents 570337b + 8cd51e7 commit e389708
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion test/SyncAsyncFileSystemDecorator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const fs = require("fs");
const path = require("path");
const SyncAsyncFileSystemDecorator = require("../lib/SyncAsyncFileSystemDecorator");

describe("SyncAsyncFileSystemDecorator stat", function () {
describe("SyncAsyncFileSystemDecorator stat", function () {
it("should use options when they're provided", function (done) {
const decoratedFs = new SyncAsyncFileSystemDecorator(fs);
decoratedFs.stat(
Expand Down Expand Up @@ -38,3 +38,42 @@ describe("SyncAsyncFileSystemDecorator stat", function () {
);
});
});

describe("SyncAsyncFileSystemDecorator lstat", function () {
it("should use options when they're provided", function (done) {
const decoratedFs = new SyncAsyncFileSystemDecorator(fs);
if (decoratedFs.lstat) {
decoratedFs.lstat(
path.join(__dirname, "fixtures", "decorated-fs", "exists.js"),
{ bigint: true },
function (error, result) {
expect(error).toBeNull();
expect(result).toHaveProperty("size");
expect(result).toHaveProperty("birthtime");
expect(
typeof (/** @type {import("fs").BigIntStats} */ (result).size)
).toEqual("bigint");
done();
}
);
}
});

it("should work correctly when no options provided", function (done) {
const decoratedFs = new SyncAsyncFileSystemDecorator(fs);
if (decoratedFs.lstat) {
decoratedFs.lstat(
path.join(__dirname, "fixtures", "decorated-fs", "exists.js"),
function (error, result) {
expect(error).toBeNull();
expect(result).toHaveProperty("size");
expect(result).toHaveProperty("birthtime");
expect(
typeof (/** @type {import("fs").Stats} */ (result).size)
).toEqual("number");
done();
}
);
}
});
});

0 comments on commit e389708

Please sign in to comment.