salat 4.9.4 → 4.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { API_URL } from "#services/constants";
|
|
2
2
|
import fetch from "node-fetch";
|
|
3
|
+
import https from "https";
|
|
4
|
+
const agent = new https.Agent({
|
|
5
|
+
rejectUnauthorized: false,
|
|
6
|
+
});
|
|
3
7
|
export const getData = async (cityId) => {
|
|
4
|
-
const response = await fetch(`${API_URL}?ville=${cityId}
|
|
8
|
+
const response = await fetch(`${API_URL}?ville=${cityId}`, { agent });
|
|
5
9
|
return await response.text();
|
|
6
10
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
2
|
import * as constants from "../constants.js";
|
|
3
3
|
vi.mock("node-fetch");
|
|
4
|
+
vi.mock("https");
|
|
4
5
|
import fetch from "node-fetch";
|
|
5
6
|
import { getData } from "./api.js";
|
|
6
7
|
describe("api utils", () => {
|
|
@@ -14,7 +15,9 @@ describe("api utils", () => {
|
|
|
14
15
|
text: async () => mockResponse,
|
|
15
16
|
});
|
|
16
17
|
const result = await getData(1);
|
|
17
|
-
expect(fetch).toHaveBeenCalledWith(`${constants.API_URL}?ville=1
|
|
18
|
+
expect(fetch).toHaveBeenCalledWith(`${constants.API_URL}?ville=1`, expect.objectContaining({
|
|
19
|
+
agent: expect.any(Object),
|
|
20
|
+
}));
|
|
18
21
|
expect(result).toBe(mockResponse);
|
|
19
22
|
});
|
|
20
23
|
it("should throw error if fetch fails", async () => {
|