test: mock the fs.promises.access function to prevent false test fail

This commit is contained in:
Jelle Glebbeek
2021-05-20 22:04:55 +02:00
parent b4e7ddbd28
commit 5bb053b8a5

View File

@@ -29,6 +29,7 @@ describe("getLocalVersion", () => {
});
it('returns the version property from the json file', () => {
jest.spyOn(fs.promises, 'readFile').mockResolvedValue("{\"version\": \"v2.0.0-test1\"}")
jest.spyOn(fs.promises, 'access').mockResolvedValue("");
const instance = new BinaryUpdater({ ytdlVersion: "a/test/path" });
return instance.getLocalVersion().then((data) => {
expect(data).toBe("v2.0.0-test1");