add simple test for blob uploads

This commit is contained in:
Henry 2020-10-19 09:27:19 +02:00
parent e7dd215f4d
commit 4884f264fd
2 changed files with 29 additions and 0 deletions

View File

@ -70,6 +70,35 @@ paths.forEach((path) => {
});
});
// basic blob
tap.test("preview with blob", (t) => {
// TODO: i bet there must be something like beautfiul soup for nodejs, right?
let textRe = /hello testworld!/;
let blobRe = /\[128zeros\]\((&[0-9a-zA-Z]+=.sha256)\)/;
supertest(app)
.post("/publish/preview")
.field("text", "hello testworld!")
.attach("blob", "test/fixtures/128zeros")
.set("Referer", "http://localhost/publish/preview")
.set("Host", "localhost")
.set("Accept", "text/html")
.expect(200, textRe)
.expect((res) => {
let found = res.text.match(blobRe);
t.notEqual(found, null, "body did not match blob regexp");
t.true(found.length >= 1, `expected ${found.length} >= 1`);
t.equal(
found[1],
"&OHI6Ll6KF6p5UNwAggmUTomPaae9EKI8g500HpNf1co=.sha256"
);
})
.end((err) => {
t.equal(err, null);
console.log("done: preview with blob");
t.end();
});
});
// HACK: This closes the database.
tap.teardown(() => {
app.close();

BIN
test/fixtures/128zeros vendored Normal file

Binary file not shown.