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

lint

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