Skip to content

Commit

Permalink
Add test cases for getArticleDescriptions()
Browse files Browse the repository at this point in the history
  • Loading branch information
macbre committed Jan 26, 2023
1 parent 1762210 commit 1098e9c
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion test/wikidata-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { describe, it, expect } = require("@jest/globals");
const WikiData = require("../lib/wikidata");

describe("WikiData API", () => {
const TEST_ARTICLE = "Albert Einstein";
const TEST_ARTICLE = "Albert Einstein"; // https://www.wikidata.org/wiki/Q937
const NOT_EXISTING_ARTICLE = "FooBar39786123";
const TEST_ENTITY = "Q928875"; // Saksun
const NOT_EXISTING_ENTITY = "Q3976321987569386512312";
Expand Down Expand Up @@ -49,6 +49,28 @@ describe("WikiData API", () => {
}, 5000);
});

describe("getArticleDescriptions", () => {
it(`returns descriptions for "${TEST_ARTICLE}" article`, async () => {
const res = await client.getArticleDescriptions(TEST_ARTICLE);

expect(res.en).toEqual({
language: "en",
value:
"German-born theoretical physicist; developer of the theory of relativity (1879–1955)",
});

expect(res.pl).toEqual({
language: "pl",
value: "fizyk teoretyczny, noblista",
});
}, 5000);

it(`gives null for not existing article`, async () => {
const res = await client.getArticleDescriptions(NOT_EXISTING_ARTICLE);
expect(res).toBeNull();
}, 5000);
});

describe("getEntityClaims", () => {
it(`returns claims for "${TEST_ENTITY}" entity`, async () => {
const res = await client.getEntityClaims(TEST_ENTITY);
Expand Down

0 comments on commit 1098e9c

Please sign in to comment.