Add compatibility with Koa v1, fix tests and edit README

This commit is contained in:
Danijel Hrvacanin
2016-10-14 14:32:39 +02:00
parent 36c40daa5d
commit 66e1fca8dd
4 changed files with 67 additions and 20 deletions

View File

@@ -3,7 +3,10 @@
let express = require("express"),
supertest = require("supertest"),
bundle = require("../");
bundle = require("../"),
koa = require("koa"),
c2k = require("koa-connect"),
supertestKoa = require("supertest-koa-agent");
describe("index", () => {
it("metrics returns up=1", done => {
@@ -137,4 +140,31 @@ describe("index", () => {
});
});
});
it("Koa: metrics returns up=1", done => {
const app = koa();
const bundled = bundle({
prefix: "hello:",
whitelist: ["up"]
});
app.use(c2k(bundled));
app.use(function*(next) {
if (this.path !== "test") {
return yield next;
}
this.body = "it worked";
});
const agent = supertestKoa(app);
agent.get("/test").end(() => {
agent
.get("/metrics")
.end((err, res) => {
expect(res.status).toBe(200);
expect(res.text).toMatch(/hello:up\s1/);
done();
});
});
});
});