Skip to content
Snippets Groups Projects
Commit f50267bf authored by Gilgard's avatar Gilgard
Browse files

lint

parent 94b1d070
No related branches found
No related tags found
1 merge request!32Community member list
Pipeline #176599 passed
...@@ -12,8 +12,6 @@ ...@@ -12,8 +12,6 @@
export default { export default {
name: "HelloWorld", name: "HelloWorld",
data: () => ({ data: () => ({}),
};
}),
}
</script> </script>
...@@ -4,14 +4,13 @@ import axios from "axios"; ...@@ -4,14 +4,13 @@ import axios from "axios";
jest.mock("axios"); jest.mock("axios");
describe("testing mocking of apiutil.js", () => { describe("testing mocking of apiutil.js", () => {
it("check that login fails with wrong credentials - against mock", async () => { it("check that login fails with wrong credentials - against mock", async () => {
const loginRequest = { const loginRequest = {
email: "wrong@email.com", email: "wrong@email.com",
password: "thisiswrong123"}; password: "thisiswrong123",
};
const expectedLoginResponse = { isLoggedIn: false, token: "" } const expectedLoginResponse = { isLoggedIn: false, token: "" };
axios.post.mockImplementation(() => axios.post.mockImplementation(() =>
Promise.resolve({ data: expectedLoginResponse }) Promise.resolve({ data: expectedLoginResponse })
...@@ -19,24 +18,32 @@ describe("testing mocking of apiutil.js", () => { ...@@ -19,24 +18,32 @@ describe("testing mocking of apiutil.js", () => {
const loginResponse = await doLogin(loginRequest); const loginResponse = await doLogin(loginRequest);
expect(loginResponse.token.isLoggedIn).toEqual(expectedLoginResponse.isLoggedIn); expect(loginResponse.token.isLoggedIn).toEqual(
expectedLoginResponse.isLoggedIn
);
}); });
it("check that login succeeds when correct credentials - against mock", async () => { it("check that login succeeds when correct credentials - against mock", async () => {
const loginRequest = { const loginRequest = {
email: "correct@email.com", email: "correct@email.com",
password: "thisiscorrect123"}; password: "thisiscorrect123",
};
const apiResponse = {isLoggedIn: true, token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM" + const apiResponse = {
"0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"}; isLoggedIn: true,
token:
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM" +
"0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
};
const expectedLoginResponse = {isLoggedIn: false, token: ""}; const expectedLoginResponse = { isLoggedIn: false, token: "" };
axios.post.mockImplementation(() => Promise.resolve({ data: apiResponse })); axios.post.mockImplementation(() => Promise.resolve({ data: apiResponse }));
const loginResponse = await doLogin(loginRequest); const loginResponse = await doLogin(loginRequest);
expect(loginResponse.token.isLoggedIn).not.toEqual(expectedLoginResponse.isLoggedIn); expect(loginResponse.token.isLoggedIn).not.toEqual(
expectedLoginResponse.isLoggedIn
);
}); });
}); });
...@@ -2,48 +2,43 @@ import { shallowMount } from "@vue/test-utils"; ...@@ -2,48 +2,43 @@ import { shallowMount } from "@vue/test-utils";
import CreateNewGroup from "@/components/CreateNewGroup.vue"; import CreateNewGroup from "@/components/CreateNewGroup.vue";
describe("CreateNewGroup elements rendering", () => { describe("CreateNewGroup elements rendering", () => {
it("renders all labels", () => {
it("renders all labels", () => { const wrapper = shallowMount(CreateNewGroup);
const wrapper = shallowMount(CreateNewGroup); expect(wrapper.find("#radioBoxLabel").text()).toMatch("Synlighet");
expect(wrapper.find("#radioBoxOpenLabel").text()).toMatch("Åpen");
expect(wrapper.find('#radioBoxLabel').text()).toMatch("Synlighet"); expect(wrapper.find("#radioBoxPrivateLabel").text()).toMatch("Privat");
expect(wrapper.find('#radioBoxOpenLabel').text()).toMatch("Åpen"); expect(wrapper.find("#titleLabel").text()).toMatch("Gruppenavn");
expect(wrapper.find('#radioBoxPrivateLabel').text()).toMatch("Privat"); expect(wrapper.find("#selectCategoryLabel").text()).toMatch("Kategori");
expect(wrapper.find('#titleLabel').text()).toMatch("Gruppenavn"); expect(wrapper.find("#descriptionLabel").text()).toMatch("Beskrivelse");
expect(wrapper.find('#selectCategoryLabel').text()).toMatch("Kategori"); expect(wrapper.find("#imageLabel").text()).toMatch("Bilde");
expect(wrapper.find('#descriptionLabel').text()).toMatch("Beskrivelse"); });
expect(wrapper.find('#imageLabel').text()).toMatch("Bilde");
it("Tests setting values of input field", async () => {
}); const wrapper = shallowMount(CreateNewGroup);
it("Tests setting values of input field", async() => { const titleInput = wrapper.find("#title");
await titleInput.setValue("Fjellgata");
const wrapper = shallowMount(CreateNewGroup); expect(titleInput.element.value).toBe("Fjellgata");
const titleInput = wrapper.find('#title'); const selectedCategory = wrapper.find("#categories");
await titleInput.setValue("Fjellgata"); await selectedCategory.setValue("Borettslag");
expect(titleInput.element.value).toBe("Fjellgata"); expect(selectedCategory.element.value).toBe("Borettslag");
const selectedCategory = wrapper.find('#categories'); const descriptionInput = wrapper.find("#description");
await selectedCategory.setValue("Borettslag"); await descriptionInput.setValue("Dette er et borettslag");
expect(selectedCategory.element.value).toBe("Borettslag"); expect(descriptionInput.element.value).toBe("Dette er et borettslag");
});
const descriptionInput = wrapper.find('#description');
await descriptionInput.setValue("Dette er et borettslag"); it("Tests if radio box checks", async () => {
expect(descriptionInput.element.value).toBe("Dette er et borettslag"); const wrapper = shallowMount(CreateNewGroup);
});
const radioInputOpen = wrapper.find("#flexRadioOpen");
it("Tests if radio box checks", async() => { await radioInputOpen.setChecked();
expect(radioInputOpen.element.checked).toBeTruthy();
const wrapper = shallowMount(CreateNewGroup);
const radioInputPrivate = wrapper.find("#flexRadioPrivate");
const radioInputOpen = wrapper.find('#flexRadioOpen'); await radioInputPrivate.setChecked();
await radioInputOpen.setChecked(); expect(radioInputPrivate.element.checked).toBeTruthy();
expect(radioInputOpen.element.checked).toBeTruthy(); });
const radioInputPrivate = wrapper.find('#flexRadioPrivate');
await radioInputPrivate.setChecked();
expect(radioInputPrivate.element.checked).toBeTruthy();
});
}); });
...@@ -2,14 +2,11 @@ import { shallowMount } from "@vue/test-utils"; ...@@ -2,14 +2,11 @@ import { shallowMount } from "@vue/test-utils";
import SearchItemListComponent from "@/components/SearchItemListComponent.vue"; import SearchItemListComponent from "@/components/SearchItemListComponent.vue";
describe("CreateNewGroup elements rendering", () => { describe("CreateNewGroup elements rendering", () => {
it("Tests setting values of input field", async () => {
const wrapper = shallowMount(SearchItemListComponent);
it("Tests setting values of input field", async() => { const searchInput = wrapper.find("#searchInput");
await searchInput.setValue("Dyson");
const wrapper = shallowMount(SearchItemListComponent); expect(searchInput.element.value).toBe("Dyson");
});
const searchInput = wrapper.find('#searchInput');
await searchInput.setValue("Dyson");
expect(searchInput.element.value).toBe("Dyson");
});
}); });
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