Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updating the gateway test to use axios instead of fetch #112

Merged
merged 1 commit into from
Apr 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions packages/grid_client/tests/modules/gateways.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import axios from "axios";
import { setTimeout } from "timers/promises";

import { FilterOptions, GatewayNameModel, generateString, GridClient, MachinesModel, randomChoice } from "../../src";
Expand Down Expand Up @@ -195,7 +196,8 @@ test("TC1237 - Gateways: Expose a VM Over Gateway", async () => {
let reachable = false;

for (let i = 0; i < 30; i++) {
fetch(domain, { mode: "no-cors" })
axios
.get(domain)
.then(res => {
log("gateway is reachable");
reachable = true;
Expand All @@ -211,21 +213,17 @@ test("TC1237 - Gateways: Expose a VM Over Gateway", async () => {
}

if (reachable) {
fetch(domain, { mode: "no-cors" })
.then(res => {
log(res.status);
log(res.statusText);
expect(res.status).toBe(200);
expect(res.statusText).toBe("OK");
return res.text();
})
.then(data => {
log(data);
expect(data).toContain("Directory listing for /");
expect(data).toContain("bin/");
expect(data).toContain("dev/");
expect(data).toContain("etc/");
});
axios.get(domain).then(res => {
log(res.status);
log(res.statusText);
log(res.data);
expect(res.status).toBe(200);
expect(res.statusText).toBe("OK");
expect(res.data).toContain("Directory listing for /");
expect(res.data).toContain("bin/");
expect(res.data).toContain("dev/");
expect(res.data).toContain("etc/");
});
} else {
throw new Error("Gateway is unreachable after multiple retries");
}
Expand Down