Skip to content
Snippets Groups Projects
Commit 8bb5c465 authored by Håkon Eilertsen Røskaft's avatar Håkon Eilertsen Røskaft
Browse files

Merge branch 'rentTesting' into 'main'

Rent testing

See merge request !154
parents d7b7ae89 beb4138d
No related branches found
No related tags found
1 merge request!154Rent testing
Pipeline #182290 failed with stages
in 1 minute and 27 seconds
......@@ -42,6 +42,7 @@
</div>
<div>
<notification-modal
id="notification-modal"
@click="routeToChat"
:visible="confirmed"
:title="'Vellykket'"
......
......@@ -316,6 +316,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";
jest.mock("axios");
let mockRouter;
describe("Confirm and send a rent request", () => {
mockRouter = {
go: jest.fn()
}
let wrapper;
const route = {
params: {
id: 1,
},
};
const router = {
push: jest.fn(),
};
beforeEach(() => {
wrapper = mount(NewRent, {
props: {
......@@ -24,12 +24,11 @@ describe("Confirm and send a rent request", () => {
isAccepted: false,
},
},
global: {
mocks: {
$route: route,
$router: router,
},
},
global:{
mocks:{
$router: mockRouter
}
}
});
});
......@@ -37,10 +36,26 @@ 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 sends post request", async () => {
const button = wrapper.find("#confirmButton");
axios.post.mockResolvedValueOnce();
button.trigger("click");
await wrapper.vm.$nextTick();
expect(axios.post).toHaveBeenCalledTimes(1);
});
it("Checks that page is reloaded when cancelButton is press", async () =>{
const button = wrapper.find("#cancelButton");
button.trigger("click");
await wrapper.vm.$nextTick();
expect(mockRouter.go).toHaveBeenCalledTimes(1);
expect(mockRouter.go).toHaveBeenCalledWith(0);
})
});
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