Added JSON-serialization logic to FileInfo

This commit is contained in:
Kir_Antipov 2023-05-14 15:12:33 +00:00
parent c218b813c0
commit de17c8b440
2 changed files with 15 additions and 0 deletions

View file

@ -134,6 +134,15 @@ export class FileInfo {
toString() {
return this._path;
}
/**
* Returns the file path.
*
* @returns The file path.
*/
toJSON() {
return this._path;
}
}
/**

View file

@ -166,6 +166,12 @@ describe("FileInfo", () => {
expect(info.toString()).toBe("path/to/test.txt");
});
});
test("should be converted to JSON as a file path string", () => {
const info = new FileInfo("path/to/test.txt");
expect(JSON.stringify(info)).toBe("\"path/to/test.txt\"");
});
});
describe("fileEquals", () => {