-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgetCountryByTranslation.test.ts
More file actions
19 lines (16 loc) · 945 Bytes
/
getCountryByTranslation.test.ts
File metadata and controls
19 lines (16 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { getCountryByTranslation } from "../dist";
import { API_BASE_URL } from "../src/constants";
test("fetchs specific country by Translation correctly", async () => {
const country = await getCountryByTranslation({ translation: "alemania" });
const apiResponse = (await (await fetch(`${API_BASE_URL}/translation/alemania`)).json())[0];
expect(country).toEqual(apiResponse);
});
test("fetchs specific country with specific fields bu Translation correctly", async () => {
const country = await getCountryByTranslation({ translation: "Saksamaa", fields: ["startOfWeek", "area"] });
const apiResponse = (await (await fetch(`${API_BASE_URL}/translation/Saksamaa?fields=area,startOfWeek`)).json())[0];
expect(country).toEqual(apiResponse);
});
test("should return null", async () => {
const country = await getCountryByTranslation({ translation: "aaabccc", fields: ["startOfWeek", "area"] });
expect(country).toEqual(null);
});