many-cloud
Version:
A Node module for abstracting file management and interfacing with a variety of cloud storages.
44 lines (40 loc) • 1.1 kB
JavaScript
describe("get_file_info", () => {
describe("when the operation is successfull", () => {
const expected_result = "file_info";
let data, func;
beforeEach(() => {
data = {
client: {
files: {
get: jest.fn().mockImplementation(() => {
return expected_result;
})
}
}
};
func = require("../get_file_info")(data);
});
it("returns the expected result", async () => {
await expect(func("1234")).resolves.toEqual(expected_result);
});
});
describe("when the operation throws an error", () => {
const expected_error = "Look what you did!";
let data, func;
beforeEach(() => {
data = {
client: {
files: {
get: jest.fn().mockImplementation(() => {
throw new Error(expected_error);
})
}
}
};
func = require("../get_file_info")(data);
});
it("rejects with the error", async () => {
await expect(func("1234")).rejects.toThrowErrorMatchingSnapshot();
});
});
});