2020-03-19 03:41:40 +01:00
|
|
|
import { developmentWebServer, emailServer, feedPath } from ".";
|
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
|
|
|
|
2020-03-19 02:44:21 +01:00
|
|
|
test("create feed", async () => {
|
2020-03-19 04:36:02 +01:00
|
|
|
const token = await createFeed();
|
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
|
|
|
|
2020-03-19 04:36:02 +01:00
|
|
|
test("receive email", async () => {
|
|
|
|
const token = await createFeed();
|
|
|
|
})
|
|
|
|
|
2020-03-19 01:16:00 +01:00
|
|
|
afterAll(() => {
|
2020-03-19 02:44:21 +01:00
|
|
|
developmentWebServer.close();
|
2020-03-19 03:41:40 +01:00
|
|
|
emailServer.close(() => {});
|
2020-03-19 01:16:00 +01:00
|
|
|
});
|
2020-03-19 04:36:02 +01:00
|
|
|
|
|
|
|
async function createFeed(): Promise<string> {
|
|
|
|
const response = await fetch("http://localhost:8000", {
|
|
|
|
method: "POST",
|
|
|
|
body: new URLSearchParams({ name: "My Feed" })
|
|
|
|
});
|
|
|
|
const responseText = await response.text();
|
|
|
|
return responseText.match(/(\w{20}).xml/)![1];
|
|
|
|
}
|