mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-11-21 16:00:59 -05:00
Added JSON-serialization logic to FileInfo
This commit is contained in:
parent
c218b813c0
commit
de17c8b440
2 changed files with 15 additions and 0 deletions
|
@ -134,6 +134,15 @@ export class FileInfo {
|
|||
toString() {
|
||||
return this._path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the file path.
|
||||
*
|
||||
* @returns The file path.
|
||||
*/
|
||||
toJSON() {
|
||||
return this._path;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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", () => {
|
||||
|
|
Loading…
Reference in a new issue