Skip to content
Snippets Groups Projects
Commit 66dd170a authored by henrikburmann's avatar henrikburmann
Browse files

Struggling with axios tests

parent c9fb7a01
1 merge request!154Rent testing
......@@ -42,6 +42,7 @@
</div>
<div>
<notification-modal
id="notification-modal"
@click="routeToHome"
:visible="confirmed"
:title="'Vellykket'"
......
......@@ -311,6 +311,7 @@ export default {
.cardContainer {
position: relative;
}
.DotButton {
position: absolute;
right: 40px;
......
import { mount } from "@vue/test-utils";
import NewRent from "@/components/RentingComponents/NewRent.vue";
import axios from "axios";
describe("Confirm and send a rent request", () => {
let wrapper;
const route = {
params: {
id: 1,
jest.mock("@/utils/token-utils", () => {
return {
tokenHeader: () => {
return {};
},
parseCurrentUser: () => {
return { accountId: 1 };
},
};
const router = {
push: jest.fn(),
};
});
jest.mock("axios");
describe("Confirm and send a rent request", () => {
let wrapper;
beforeEach(() => {
wrapper = mount(NewRent, {
props: {
......@@ -24,12 +30,6 @@ describe("Confirm and send a rent request", () => {
isAccepted: false,
},
},
global: {
mocks: {
$route: route,
$router: router,
},
},
});
});
......@@ -37,10 +37,23 @@ describe("Confirm and send a rent request", () => {
expect(wrapper.exists()).toBeTruthy();
});
it("Check if fields show correct informations", () => {
it("Check that fields show correct informations", () => {
expect(wrapper.find("#rentTitle").text()).toEqual("Telt");
expect(wrapper.find("#fromTime").text()).toMatch("19. September 2022");
expect(wrapper.find("#toTime").text()).toMatch("23. September 2022");
expect(wrapper.find("#price").text()).toEqual("Totaltpris: 200 kr");
});
it("Check that clicking rent opens confirmbox",async () => {
wrapper.find("#confirmButton").trigger("click");
// await wrapper.vm.$nextTick();
await axios.put.mockResolvedValueOnce(props.newRentBox);
// expect(wrapper.find("notification-modal").exists()).toBeTruthy();
expect(axios.post).toHaveBeenCalledTimes(1);
})
});
......@@ -34,4 +34,8 @@ describe("UserItems component", () => {
it("Check headline", () => {
expect(wrapper.find("#headline").text()).toMatch("Mine gjenstander");
});
// it("Check title", () => {
// expect(wrapper.findAll(".ItemCardPage")[0].exists()).toBeTruthy();
// })
});
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