kill-the-newsletter/src/test.ts

20 lines
516 B
TypeScript
Raw Normal View History

2020-03-19 01:21:04 +01:00
import { webServer, feedPath } from "./server";
2020-03-19 01:16:00 +01:00
import fetch from "node-fetch";
2020-03-18 20:33:10 +01:00
import fs from "fs";
2020-03-18 20:21:44 +01:00
test("create feed", async () => {
2020-03-19 01:16:00 +01:00
const response = await fetch("http://localhost:8443", {
method: "POST",
body: new URLSearchParams({ name: "My Feed" })
});
const responseText = await response.text();
const token = responseText.match(/(\w{20}).xml/)![1];
2020-03-18 20:33:10 +01:00
const feed = fs.readFileSync(feedPath(token)).toString();
expect(feed).toMatch("My Feed");
2020-03-18 20:21:44 +01:00
});
2020-03-19 01:16:00 +01:00
afterAll(() => {
webServer.close();
});