const test = require("ava");
const path = require("path");
const request = require("supertest");
process.chdir(path.resolve(__dirname, "./testsite/"));
const config = require(path.resolve(__dirname, "../src/modules/config.js"));
const app = require("../src/app.js");
test("homepage", t => {
return request(app.listen())
.get("/")
.expect(200)
.expect(/
Test Site<\/title>/)
.expect(/Test Site<\/h1>/)
.expect(/This is a test/)
.then(() => t.pass());
});
test("post", t => {
return request(app.listen())
.get("/post/testfile")
.expect(200)
.expect(/Lorem ipsum<\/h1>/)
.then(() => t.pass());
});
test("post not found", t => {
return request(app.listen())
.get("/post/non-existant")
.expect(404)
.expect(/Post not found/)
.then(() => t.pass());
});
test("tags", t => {
return request(app.listen())
.get("/tag/a")
.expect(200)
.expect(/This is a test/)
.then(() => t.pass());
});
test("tags not found", t =>
request(app.listen())
.get("/tag/non-existant")
.expect(404)
.expect(/tag non-existant not found/)
.then(() => t.pass()));