/
index.test.ts
61 lines (49 loc) · 1.67 KB
/
index.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { test } from "@paperpod/common";
import { withStorageUri } from ".";
import { withTextualData, getRSSFeed } from "./index";
describe("converter", () => {
jest.mock("zombie");
describe("withTextualData", () => {
it("Does not throw", () => {
expect(withTextualData(test.mocks.article())).resolves.not.toThrow();
});
it("Does return article data", async () => {
const original = test.mocks.article();
const withData = await withTextualData(original);
expect(withData.text).not.toEqual(original.text);
expect(withData.title).not.toEqual(original.title);
expect(withData.author).not.toEqual(original.author);
});
});
describe("Getting RSS feed", () => {
it("does not crash", () => {
expect(() => {
getRSSFeed([test.mocks.article()]);
}).not.toThrow();
});
//NOTE: this is properly unit tested in `rss.test.ts`
it("Does return something looking like an XML feed", () => {
const feed = getRSSFeed([test.mocks.article()]);
expect(feed).toContain("<channel>");
});
it("Does return a feed with data from the articles", () => {
const articles = [
test.mocks.article(),
test.mocks.article(),
test.mocks.article(),
];
const feed = getRSSFeed(articles);
articles.forEach((article) => {
expect(feed).toContain(article.title);
});
});
});
describe("withStorageUri", () => {
jest.mock("@aws-sdk/client-polly");
jest.mock("@aws-sdk/client-comprehend");
it("Does not throw", async () => {
const article = await withStorageUri(test.mocks.article());
expect(article).toBeDefined();
});
});
});