Skip to content

Commit

Permalink
LoginForm.test.ts cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Nov 21, 2024
1 parent 6dd94c8 commit 9ea0682
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions client/src/components/Login/LoginForm.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import { createTestingPinia } from "@pinia/testing";
import { getLocalVue } from "@tests/jest/helpers";
import { mount } from "@vue/test-utils";
import axios from "axios";
import MockAdapter from "axios-mock-adapter";
import flushPromises from "flush-promises";

import { useServerMock } from "@/api/client/__mocks__";
import { HttpResponse } from "@/api/client/__mocks__/index"

import MountTarget from "./LoginForm.vue";

const localVue = getLocalVue(true);
const testingPinia = createTestingPinia({ stubActions: false });

const { server, http } = useServerMock();

async function mountLoginForm() {
const wrapper = mount(MountTarget as object, {
Expand All @@ -16,6 +24,7 @@ async function mountLoginForm() {
stubs: {
ExternalLogin: true,
},
pinia: testingPinia,
});

return wrapper;
Expand All @@ -26,6 +35,11 @@ describe("LoginForm", () => {

beforeEach(() => {
axiosMock = new MockAdapter(axios);
server.use(
http.get("/api/configuration", ({ response }) => {
return response.untyped(HttpResponse.json({oidc: {cilogon: false, custos: false }}));
})
);
});

afterEach(() => {
Expand Down Expand Up @@ -62,8 +76,6 @@ describe("LoginForm", () => {
it("props", async () => {
const wrapper = await mountLoginForm();

console.log(wrapper.html());

const $register = "#register-toggle";
expect(wrapper.findAll($register).length).toBe(0);

Expand All @@ -79,6 +91,7 @@ describe("LoginForm", () => {

const welcomePage = wrapper.find("iframe");
expect(welcomePage.attributes("src")).toBe("welcome_url");
await flushPromises();
});

it("connect external provider", async () => {
Expand Down Expand Up @@ -126,5 +139,6 @@ describe("LoginForm", () => {

const postedURL = axiosMock.history.post?.[0]?.url;
expect(postedURL).toBe("/user/login");
await flushPromises();
});
});

0 comments on commit 9ea0682

Please sign in to comment.