diff --git a/src/components/RentingComponents/NewRent.vue b/src/components/RentingComponents/NewRent.vue index f0609f0ccaa7515c53d4839578ae77dca6bd510b..5b2647e4dbe76e592887f7464862293cc07792d3 100644 --- a/src/components/RentingComponents/NewRent.vue +++ b/src/components/RentingComponents/NewRent.vue @@ -42,6 +42,7 @@ </div> <div> <notification-modal + id="notification-modal" @click="routeToChat" :visible="confirmed" :title="'Vellykket'" diff --git a/src/components/UserProfileComponents/UserItems.vue b/src/components/UserProfileComponents/UserItems.vue index dd0ca9c8e80d0e0b320389321633aa4cf63763cd..ac1736b5e713e14625729087f0493c4b859e55bf 100644 --- a/src/components/UserProfileComponents/UserItems.vue +++ b/src/components/UserProfileComponents/UserItems.vue @@ -316,6 +316,7 @@ export default { .cardContainer { position: relative; } + .DotButton { position: absolute; right: 40px; diff --git a/tests/unit/component-tests/renting-compnents-tests/new-rent.spec.js b/tests/unit/component-tests/renting-compnents-tests/new-rent.spec.js index 3f8ffafa68bf5dd606afdeda9214b57871ff174f..c4cb88e85e7a68134b52dba817ebd7375e29888b 100644 --- a/tests/unit/component-tests/renting-compnents-tests/new-rent.spec.js +++ b/tests/unit/component-tests/renting-compnents-tests/new-rent.spec.js @@ -1,16 +1,16 @@ 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); + }) });