diff --git a/test/basic.js b/test/basic.js index 56d547f..67cfcf2 100644 --- a/test/basic.js +++ b/test/basic.js @@ -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(); diff --git a/test/fixtures/128zeros b/test/fixtures/128zeros new file mode 100644 index 0000000..00bc047 Binary files /dev/null and b/test/fixtures/128zeros differ