diff --git a/src/components/ChatComponents/ChatMessage.vue b/src/components/ChatComponents/ChatMessage.vue index 58720e89792b63889b4de9db9f870e47fc4eeeeb..d3e016a3d4b947d0b90cedb3ea9e07093a47a206 100644 --- a/src/components/ChatComponents/ChatMessage.vue +++ b/src/components/ChatComponents/ChatMessage.vue @@ -47,7 +47,7 @@ export default { calculateTime() { //let time = this.message.from; // Calculate time when message was sent - let date = new Date(Date.now()); + let date = new Date(this.message.timestamp); let hours = date.getHours(); let minutes = "0" + date.getMinutes(); let formattedTime = hours + ":" + minutes.substr(-2); diff --git a/tests/unit/apiutil-communityHome-mock.spec.js b/tests/unit/api-mock-tests/apiutil-communityHome-mock.spec.js similarity index 100% rename from tests/unit/apiutil-communityHome-mock.spec.js rename to tests/unit/api-mock-tests/apiutil-communityHome-mock.spec.js diff --git a/tests/unit/apiutil-login-mock.spec.js b/tests/unit/api-mock-tests/apiutil-login-mock.spec.js similarity index 100% rename from tests/unit/apiutil-login-mock.spec.js rename to tests/unit/api-mock-tests/apiutil-login-mock.spec.js diff --git a/tests/unit/apiutil-user-mock.spec.js b/tests/unit/api-mock-tests/apiutil-user-mock.spec.js similarity index 100% rename from tests/unit/apiutil-user-mock.spec.js rename to tests/unit/api-mock-tests/apiutil-user-mock.spec.js diff --git a/tests/unit/component-tests/base-component-tests/__snapshots__/color-button.spec.js.snap b/tests/unit/component-tests/base-component-tests/__snapshots__/color-button.spec.js.snap new file mode 100644 index 0000000000000000000000000000000000000000..4a8d6370547ec8f2d5faee8131dc1432a0d3a7e5 --- /dev/null +++ b/tests/unit/component-tests/base-component-tests/__snapshots__/color-button.spec.js.snap @@ -0,0 +1,9 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ColoredButtonComponent renders correctly 1`] = ` +<button + class="block text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800" +> + hei +</button> +`; diff --git a/tests/unit/component-tests/base-component-tests/__snapshots__/community-header.spec.js.snap b/tests/unit/component-tests/base-component-tests/__snapshots__/community-header.spec.js.snap new file mode 100644 index 0000000000000000000000000000000000000000..37c7707a55225271b1c8e987ad9823f7d248ccd4 --- /dev/null +++ b/tests/unit/component-tests/base-component-tests/__snapshots__/community-header.spec.js.snap @@ -0,0 +1,64 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`CommunityHeader component renders correctly 1`] = ` +<div + class="flex items-center justify-between mx-4" +> + <div + class="flex-1 min-w-0" + > + <h2 + class="text-2xl font-bold leading-7 text-gray-900 sm:text-3xl sm:truncate" + > + String + </h2> + <div + class="mt-1 flex flex-col sm:flex-row sm:flex-wrap sm:mt-0 sm:space-x-6" + > + <div + class="mt-2 flex items-center text-sm text-gray-500" + > + <svg + aria-hidden="true" + class="flex-shrink-0 mr-1.5 h-5 w-5 text-gray-400" + fill="currentColor" + viewBox="0 0 20 20" + xmlns="http://www.w3.org/2000/svg" + > + <path + clip-rule="evenodd" + d="M5.05 4.05a7 7 0 119.9 9.9L10 18.9l-4.95-4.95a7 7 0 010-9.9zM10 11a2 2 0 100-4 2 2 0 000 4z" + fill-rule="evenodd" + /> + </svg> + String + </div> + </div> + </div> + <div + class="flex" + > + <span + class="hidden sm:block" + > + <button + class="inline-flex items-center px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" + type="button" + > + <!-- Heroicon name: solid/pencil --> + <svg + class="h-5 w-5" + fill="currentColor" + viewBox="0 0 20 20" + xmlns="http://www.w3.org/2000/svg" + > + <path + d="M13.586 3.586a2 2 0 112.828 2.828l-.793.793-2.828-2.828.793-.793zM11.379 5.793L3 14.172V17h2.828l8.38-8.379-2.83-2.828z" + /> + </svg> + Edit + </button> + </span> + </div> +</div> +`; diff --git a/tests/unit/component-tests/base-component-tests/__snapshots__/custom-footer-modal.spec.js.snap b/tests/unit/component-tests/base-component-tests/__snapshots__/custom-footer-modal.spec.js.snap new file mode 100644 index 0000000000000000000000000000000000000000..f178175b1fa2913054cc18585b8dd831f1099858 --- /dev/null +++ b/tests/unit/component-tests/base-component-tests/__snapshots__/custom-footer-modal.spec.js.snap @@ -0,0 +1,73 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`IconButtonComponent renders correctly 1`] = ` +<div + data-v-app="" +> + + <!-- Main modal --> + <div + class="fixed grid place-items-center bg-gray-600 bg-opacity-50 top-0 left-0 right-0 z-50 w-full overflow-x-hidden overflow-y-auto md:inset-0 h-modal md:h-full" + > + <div + class="relative w-full h-full max-w-2xl p-4 md:h-auto" + > + <!-- Modal content --> + <div + class="relative bg-white rounded-lg shadow dark:bg-gray-700" + > + <!-- Modal header --> + <div + class="flex items-start justify-between p-4 border-b rounded-t dark:border-gray-600" + > + <h3 + class="text-xl font-semibold text-gray-900 dark:text-white" + > + String + </h3> + <button + class="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm p-1.5 ml-auto inline-flex items-center dark:hover:bg-gray-600 dark:hover:text-white" + > + <svg + class="w-5 h-5" + fill="currentColor" + viewBox="0 0 20 20" + xmlns="http://www.w3.org/2000/svg" + > + <path + clip-rule="evenodd" + d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" + fill-rule="evenodd" + /> + </svg> + </button> + </div> + <!-- Modal body --> + <div + class="p-6 space-y-6" + > + <p + class="text-base leading-relaxed text-gray-500 dark:text-gray-400" + > + String + </p> + </div> + <!-- Modal footer --> + <div + class="rounded-b border-t border-gray-200 dark:border-gray-600" + > + <!-- Slot: Add any html you want here --> + + <div + class="fake-msg" + > + String + </div> + + </div> + </div> + </div> + </div> + +</div> +`; diff --git a/tests/unit/component-tests/base-component-tests/__snapshots__/icon-button.spec.js.snap b/tests/unit/component-tests/base-component-tests/__snapshots__/icon-button.spec.js.snap new file mode 100644 index 0000000000000000000000000000000000000000..62007d4ff8d81f1ece9bf91271163ca179d7383d --- /dev/null +++ b/tests/unit/component-tests/base-component-tests/__snapshots__/icon-button.spec.js.snap @@ -0,0 +1,43 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`IconButtonComponent renders correctly 1`] = ` +<div + data-v-app="" +> + + <!-- Icon button --> + <button + class="block w-fit text-white text-base bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800" + > + <div + class="flex flex-row px-5 py-2.5 h-10" + > + <!-- Icon slot: Default content "Ban"-icon --> + <div + class="h-6 w-6" + > + + <svg + aria-hidden="true" + fill="none" + stroke="currentColor" + stroke-width="2" + viewBox="0 0 24 24" + xmlns="http://www.w3.org/2000/svg" + > + <path + d="M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728A9 9 0 015.636 5.636m12.728 12.728L5.636 5.636" + stroke-linecap="round" + stroke-linejoin="round" + /> + </svg> + + </div> + <p> + hei + </p> + </div> + </button> + +</div> +`; diff --git a/tests/unit/component-tests/base-component-tests/__snapshots__/notification-modal.spec.js.snap b/tests/unit/component-tests/base-component-tests/__snapshots__/notification-modal.spec.js.snap new file mode 100644 index 0000000000000000000000000000000000000000..6c2259b3f623090effe8ff37ced149d9e72da832 --- /dev/null +++ b/tests/unit/component-tests/base-component-tests/__snapshots__/notification-modal.spec.js.snap @@ -0,0 +1,60 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`NotificationModal component renders correctly 1`] = ` +<div + data-v-app="" +> + + <!-- Main modal --> + <div + class="fixed grid place-items-center bg-gray-600 bg-opacity-50 top-0 left-0 right-0 z-50 w-full overflow-x-hidden overflow-y-auto md:inset-0 h-modal md:h-full" + > + <div + class="relative w-full h-full max-w-2xl p-4 md:h-auto" + > + <!-- Modal content --> + <div + class="relative bg-white rounded-lg shadow dark:bg-gray-700" + > + <!-- Modal header --> + <div + class="flex items-start justify-between p-4 border-b rounded-t dark:border-gray-600" + > + <h3 + class="text-xl font-semibold text-gray-900 dark:text-white" + > + String + </h3> + <button + class="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm p-1.5 ml-auto inline-flex items-center dark:hover:bg-gray-600 dark:hover:text-white" + > + <svg + class="w-5 h-5" + fill="currentColor" + viewBox="0 0 20 20" + xmlns="http://www.w3.org/2000/svg" + > + <path + clip-rule="evenodd" + d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" + fill-rule="evenodd" + /> + </svg> + </button> + </div> + <!-- Modal body --> + <div + class="p-6 space-y-6" + > + <p + class="text-base leading-relaxed text-gray-500 dark:text-gray-400" + > + String + </p> + </div> + </div> + </div> + </div> + +</div> +`; diff --git a/tests/unit/component-tests/base-component-tests/color-button.spec.js b/tests/unit/component-tests/base-component-tests/color-button.spec.js new file mode 100644 index 0000000000000000000000000000000000000000..f4e8a11d706cc3b757b4c238c808011af94de192 --- /dev/null +++ b/tests/unit/component-tests/base-component-tests/color-button.spec.js @@ -0,0 +1,23 @@ +import { mount } from "@vue/test-utils"; +import ColoredButton from "@/components/BaseComponents/ColoredButton.vue" + +describe("ColoredButtonComponent", () => { + let wrapper; + + beforeEach(() => { + wrapper = mount(ColoredButton, { + //passing prop to component + props: { + text: "hei" + } + }); + }); + + it("renders correctly", () => { + expect(wrapper.element).toMatchSnapshot(); + }); + + it("is instantiated", () => { + expect(wrapper.exists()).toBeTruthy(); + }); +}); \ No newline at end of file diff --git a/tests/unit/component-tests/base-component-tests/community-header.spec.js b/tests/unit/component-tests/base-component-tests/community-header.spec.js new file mode 100644 index 0000000000000000000000000000000000000000..2195ce373c26c2a664afdd49e97641529d84ff5d --- /dev/null +++ b/tests/unit/component-tests/base-component-tests/community-header.spec.js @@ -0,0 +1,31 @@ +import { mount } from "@vue/test-utils"; +import CommunityHeader from "@/components/BaseComponents/CommunityHeader.vue" + +describe("CommunityHeader component", () => { + let wrapper; + + beforeEach(() => { + wrapper = mount(CommunityHeader, { + //passing prop to component + props: { + adminStatus: true, + community: { + communityId: 1, + name: "String", + description: "String", + visibility: 0, + location: "String", + picture: "String", + }, + } + }); + }); + + it("renders correctly", () => { + expect(wrapper.element).toMatchSnapshot(); + }); + + it("is instantiated", () => { + expect(wrapper.exists()).toBeTruthy(); + }); +}); \ No newline at end of file diff --git a/tests/unit/component-tests/base-component-tests/custom-footer-modal.spec.js b/tests/unit/component-tests/base-component-tests/custom-footer-modal.spec.js new file mode 100644 index 0000000000000000000000000000000000000000..78af6ef591ce36420890d664cdf7c37076511e00 --- /dev/null +++ b/tests/unit/component-tests/base-component-tests/custom-footer-modal.spec.js @@ -0,0 +1,28 @@ +import { mount } from "@vue/test-utils"; +import CustomFooterModal from "@/components/BaseComponents/CustomFooterModal.vue" + +describe("IconButtonComponent", () => { + let wrapper; + + beforeEach(() => { + wrapper = mount(CustomFooterModal, { + //passing prop to component + props: { + visible: true, + title: "String", + message: "String", + }, + slots: { + default: '<div class="fake-msg">String</div>' + } + }); + }); + + it("renders correctly", () => { + expect(wrapper.element).toMatchSnapshot(); + }); + + it("is instantiated", () => { + expect(wrapper.exists()).toBeTruthy(); + }); +}); \ No newline at end of file diff --git a/tests/unit/component-tests/base-component-tests/icon-button.spec.js b/tests/unit/component-tests/base-component-tests/icon-button.spec.js new file mode 100644 index 0000000000000000000000000000000000000000..a45c915a6439cf3847ff0d09bc0a0ab24e386f82 --- /dev/null +++ b/tests/unit/component-tests/base-component-tests/icon-button.spec.js @@ -0,0 +1,23 @@ +import { mount } from "@vue/test-utils"; +import IconButton from "@/components/BaseComponents/IconButton.vue" + +describe("IconButtonComponent", () => { + let wrapper; + + beforeEach(() => { + wrapper = mount(IconButton, { + //passing prop to component + props: { + text: "hei" + } + }); + }); + + it("renders correctly", () => { + expect(wrapper.element).toMatchSnapshot(); + }); + + it("is instantiated", () => { + expect(wrapper.exists()).toBeTruthy(); + }); +}); \ No newline at end of file diff --git a/tests/unit/component-tests/base-component-tests/notification-modal.spec.js b/tests/unit/component-tests/base-component-tests/notification-modal.spec.js new file mode 100644 index 0000000000000000000000000000000000000000..8db68edc59a23e8164b35db818cc47b256743959 --- /dev/null +++ b/tests/unit/component-tests/base-component-tests/notification-modal.spec.js @@ -0,0 +1,25 @@ +import { mount } from "@vue/test-utils"; +import NotificationModal from "@/components/BaseComponents/NotificationModal.vue" + +describe("NotificationModal component", () => { + let wrapper; + + beforeEach(() => { + wrapper = mount(NotificationModal, { + //passing prop to component + props: { + visible: true, + title: "String", + message: "String", + } + }); + }); + + it("renders correctly", () => { + expect(wrapper.element).toMatchSnapshot(); + }); + + it("is instantiated", () => { + expect(wrapper.exists()).toBeTruthy(); + }); +}); \ No newline at end of file diff --git a/tests/unit/component-tests/chat-component-tests/__snapshots__/chat-message.spec.js.snap b/tests/unit/component-tests/chat-component-tests/__snapshots__/chat-message.spec.js.snap new file mode 100644 index 0000000000000000000000000000000000000000..8efff294b5832ec0ee00f03ea22867e910f84607 --- /dev/null +++ b/tests/unit/component-tests/chat-component-tests/__snapshots__/chat-message.spec.js.snap @@ -0,0 +1,23 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ChatMessageComponent renders correctly 1`] = ` +<div + class="w-full break-words flex justify-start" +> + <div + class="bg-gray-300 rounded px-5 py-2 my-2 relative text-gray-900" + style="max-width: 70%;" + > + <span + class="block" + > + string 1 + </span> + <span + class="block text-xs text-right" + > + 10:20 + </span> + </div> +</div> +`; diff --git a/tests/unit/component-tests/chat-component-tests/chat-message.spec.js b/tests/unit/component-tests/chat-component-tests/chat-message.spec.js new file mode 100644 index 0000000000000000000000000000000000000000..074623e7eb05f8c5768183c903fe9bc556a200d3 --- /dev/null +++ b/tests/unit/component-tests/chat-component-tests/chat-message.spec.js @@ -0,0 +1,34 @@ +import { mount } from "@vue/test-utils"; +import ChatMessage from "@/components/ChatComponents/ChatMessage.vue" + +describe("ChatMessageComponent", () => { + let wrapper; + + beforeEach(() => { + wrapper = mount(ChatMessage, { + //passing prop to component + computed: { + userID() { + return 1; + } + }, + props: { + message: { + id: 1, + content: "string", + timestamp: "2022-04-29T08:20:42.850Z", + from: 1, + to: 3 + } + } + }); + }); + + it("renders correctly", () => { + expect(wrapper.element).toMatchSnapshot(); + }); + + it("is instantiated", () => { + expect(wrapper.exists()).toBeTruthy(); + }); +}); \ No newline at end of file diff --git a/tests/unit/component-tests/community-component-tests/__snapshots__/community-list-item.spec.js.snap b/tests/unit/component-tests/community-component-tests/__snapshots__/community-list-item.spec.js.snap new file mode 100644 index 0000000000000000000000000000000000000000..c68960ae055e412570e015fc9b92e74c0acd58d7 --- /dev/null +++ b/tests/unit/component-tests/community-component-tests/__snapshots__/community-list-item.spec.js.snap @@ -0,0 +1,35 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`CommunityListItem component renders correctly 1`] = ` +<div + class="bg-white shadow dark:bg-gray-800 select-none cursor-pointer hover:bg-gray-50 flex items-center p-4" +> + <div + class="h-10 w-10 flex flex-col justify-center items-center mr-4" + > + <img + alt="groupIMG" + src="" + /> + </div> + <div + class="flex-1 pl-1" + > + <div + class="font-medium dark:text-white" + > + string + </div> + </div> + <div + class="flex flex-row justify-center" + > + <!--v-if--> + <button + class="px-4 py-2 w-24 font-medium tracking-wide text-white capitalize transition-colors duration-200 transform bg-blue-600 rounded-md hover:bg-blue-500 focus:outline-none focus:ring focus:ring-blue-300 focus:ring-opacity-80" + > + GÃ¥ til + </button> + </div> +</div> +`; diff --git a/tests/unit/component-tests/community-component-tests/__snapshots__/create-new-group.spec.js.snap b/tests/unit/component-tests/community-component-tests/__snapshots__/create-new-group.spec.js.snap new file mode 100644 index 0000000000000000000000000000000000000000..a9b5043d55edf9d7bd0a52eb64e803ffc04f50e5 --- /dev/null +++ b/tests/unit/component-tests/community-component-tests/__snapshots__/create-new-group.spec.js.snap @@ -0,0 +1,181 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`CreateNewGroup elements rendering renders correctly 1`] = ` +<div + class="m-6" +> + <!-- Component heading --> + <div + class="flex justify-center mt-6" + > + <p + class="text-4xl" + > + Opprett Gruppe + </p> + </div> + <!-- Radio boxes --> + <div + class="mt-6" + > + <label + class="block mb-2 text-sm font-medium text-gray-900 dark:text-gray-300" + id="radioBoxLabel" + > + Synlighet + </label> + <div + class="form-check" + > + <input + class="form-check-input appearance-none rounded-full h-4 w-4 border border-gray-300 bg-white checked:bg-blue-600 checked:border-blue-600 focus:outline-none transition duration-200 mt-1 align-top bg-no-repeat bg-center bg-contain float-left mr-2 cursor-pointer" + id="flexRadioOpen" + name="flexRadioDefault" + type="radio" + value="Ã…pen" + /> + <label + class="form-check-label inline-block text-gray-800" + for="flexRadioOpen" + id="radioBoxOpenLabel" + > + Ã…pen + </label> + </div> + <div + class="form-check" + > + <input + class="form-check-input appearance-none rounded-full h-4 w-4 border border-gray-300 bg-white checked:bg-blue-600 checked:border-blue-600 focus:outline-none transition duration-200 mt-1 align-top bg-no-repeat bg-center bg-contain float-left mr-2 cursor-pointer" + id="flexRadioPrivate" + name="flexRadioDefault" + type="radio" + value="Privat" + /> + <label + class="form-check-label inline-block text-gray-800" + for="flexRadioPrivate" + id="radioBoxPrivateLabel" + > + Privat + </label> + </div> + </div> + <!-- Title --> + <div + class="mt-6" + > + <label + class="block mb-2 text-sm font-medium text-gray-900 dark:text-gray-300" + id="titleLabel" + > + Gruppenavn + </label> + <input + class="bg-gray-200 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" + id="title" + required="" + type="text" + /> + <!-- error message for title--> + + + </div> + <!-- Place --> + <div + class="mt-6" + > + <label + class="block mb-2 text-sm font-medium text-gray-900 dark:text-gray-300" + > + By/Sted + </label> + <input + class="bg-gray-200 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" + required="" + type="text" + /> + <!-- error message for place--> + + + </div> + <!-- Description --> + <div + class="mt-6" + > + <label + class="block mb-2 text-sm font-medium text-gray-900 dark:text-gray-400" + id="descriptionLabel" + > + Beskrivelse + </label> + <textarea + class="block p-2.5 w-full text-sm text-gray-900 bg-gray-200 rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" + id="description" + required="" + rows="4" + /> + <!-- error message for description --> + + + </div> + <!-- Images --> + <div + class="mt-6" + > + <label + class="block mb-2 text-xl font-medium text-gray-900 dark:text-gray-400" + id="imageLabel" + > + Bilde + </label> + <input + accept="image/png, image/jpeg" + multiple="" + style="display: none;" + type="file" + /> + <!-- Button for adding an image --> + <div + class="inline-flex rounded-md shadow-sm" + > + <div + class="text-red-500 uppercase text-center" + > + midlertidig fjernet + </div> + <!-- <button + @click="$refs.file.click()" + class="text-black bg-gray-200 hover:bg-grey-800 focus:ring-4 focus:outline-none focus:ring-grey-300 font-medium rounded-lg text-sm sm:w-auto px-5 py-2.5 text-center dark:bg-grey-600 dark:hover:bg-grey-700 dark:focus:ring-grey-800 disabled:opacity-50" + :disabled="imageAdded" + > + Velg bilde + </button> --> + <!-- Button for removing an image --> + <button + class="w-1/12 ml-5 text-white bg-white-500 font-medium rounded-lg text-sm" + style="display: none;" + > + <img + alt="Remove icon image" + src="" + /> + </button> + </div> + <!-- Div box for showing all chosen images --> + + + </div> + <!-- Save item button --> + <div + class="flex justify-center mt-10" + > + <button + class="content-center text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm sm:w-auto px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800" + id="saveButton" + > + Lagre + </button> + </div> +</div> +`; diff --git a/tests/unit/add-new-item.spec.js b/tests/unit/component-tests/community-component-tests/add-new-item.spec.js similarity index 100% rename from tests/unit/add-new-item.spec.js rename to tests/unit/component-tests/community-component-tests/add-new-item.spec.js diff --git a/tests/unit/component-tests/community-component-tests/community-list-item.spec.js b/tests/unit/component-tests/community-component-tests/community-list-item.spec.js new file mode 100644 index 0000000000000000000000000000000000000000..5349b43f4cff0d22833b9105e8038cf6a9fe3e83 --- /dev/null +++ b/tests/unit/component-tests/community-component-tests/community-list-item.spec.js @@ -0,0 +1,30 @@ +import { mount } from "@vue/test-utils"; +import CommunityListItem from "@/components/CommunityComponents/CommunityListItem.vue" + +describe("CommunityListItem component", () => { + let wrapper; + + beforeEach(() => { + wrapper = mount(CommunityListItem, { + //passing prop to component + props: { + group: { + communityId: 0, + name: "string", + description: "string", + visibility: 0, + location: "string", + picture: "string" + } + } + }); + }); + + it("renders correctly", () => { + expect(wrapper.element).toMatchSnapshot(); + }); + + it("is instantiated", () => { + expect(wrapper.exists()).toBeTruthy(); + }); +}); \ No newline at end of file diff --git a/tests/unit/create-new-group.spec.js b/tests/unit/component-tests/community-component-tests/create-new-group.spec.js similarity index 89% rename from tests/unit/create-new-group.spec.js rename to tests/unit/component-tests/community-component-tests/create-new-group.spec.js index 9ff1f2f8c528a002ee52b053533cf8df7ac78150..2110350f78d1d1703141561173eb1727e602d26e 100644 --- a/tests/unit/create-new-group.spec.js +++ b/tests/unit/component-tests/community-component-tests/create-new-group.spec.js @@ -2,9 +2,17 @@ import { shallowMount } from "@vue/test-utils"; import CreateNewGroup from "@/components/CommunityComponents/NewCommunityForm.vue"; describe("CreateNewGroup elements rendering", () => { - it("renders all labels", () => { - const wrapper = shallowMount(CreateNewGroup); + let wrapper; + + beforeEach(() => { + wrapper = shallowMount(CreateNewGroup); + }); + + it("renders correctly", () => { + expect(wrapper.element).toMatchSnapshot(); + }); + it("renders all labels", () => { expect(wrapper.find("#radioBoxLabel").text()).toMatch("Synlighet"); expect(wrapper.find("#radioBoxOpenLabel").text()).toMatch("Ã…pen"); expect(wrapper.find("#radioBoxPrivateLabel").text()).toMatch("Privat"); @@ -14,8 +22,6 @@ describe("CreateNewGroup elements rendering", () => { }); it("Tests setting values of input field", async () => { - const wrapper = shallowMount(CreateNewGroup); - const titleInput = wrapper.find("#title"); await titleInput.setValue("Fjellgata"); expect(titleInput.element.value).toBe("Fjellgata"); @@ -26,8 +32,6 @@ describe("CreateNewGroup elements rendering", () => { }); it("Tests if radio box checks", async () => { - const wrapper = shallowMount(CreateNewGroup); - const radioInputOpen = wrapper.find("#flexRadioOpen"); await radioInputOpen.setChecked(); expect(radioInputOpen.element.checked).toBeTruthy(); diff --git a/tests/unit/search-item-list.spec.js b/tests/unit/component-tests/community-component-tests/search-item-list.spec.js similarity index 100% rename from tests/unit/search-item-list.spec.js rename to tests/unit/component-tests/community-component-tests/search-item-list.spec.js diff --git a/tests/unit/__snapshots__/RegisterUserComponent.spec.js.snap b/tests/unit/component-tests/user-component-tests/__snapshots__/register-user-component.spec.js.snap similarity index 100% rename from tests/unit/__snapshots__/RegisterUserComponent.spec.js.snap rename to tests/unit/component-tests/user-component-tests/__snapshots__/register-user-component.spec.js.snap diff --git a/tests/unit/RegisterUserComponent.spec.js b/tests/unit/component-tests/user-component-tests/register-user-component.spec.js similarity index 100% rename from tests/unit/RegisterUserComponent.spec.js rename to tests/unit/component-tests/user-component-tests/register-user-component.spec.js