Skip to content
Snippets Groups Projects
Commit c4037e5c authored by Titus Netland's avatar Titus Netland
Browse files

Merge branch 'image-tests' into 'main'

api tests for image methods

See merge request !126
parents 1c392236 5516181f
No related branches found
No related tags found
1 merge request!126api tests for image methods
Pipeline #181634 failed
import { postNewImageCommunity, PostImagesArrayToListing } from "@/utils/apiutil";
import axios from "axios";
jest.mock("axios");
describe("testing mocking of apiutil.js image api calls", () => {
it("check that image gets posted", async () => {
let expectedResponse = 1;
axios.post.mockImplementation(() =>
Promise.resolve({ data: expectedResponse })
);
const imageResponse = await postNewImageCommunity("image");
expect(imageResponse).toBe(expectedResponse);
});
it("check that image array gets posted to listing", async () => {
let expectedResponse = "OK";
const imageArray = {
image1: {
image: "image1"
},
image2: {
image2: "image2"
},
};
axios.post.mockImplementation(() =>
Promise.resolve({ data: expectedResponse })
);
const imageResponse = await PostImagesArrayToListing(imageArray);
expect(imageResponse.data).toBe(expectedResponse);
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment