| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,7 @@ | |||
| 1 | 1 | // LICENSE : MIT | |
| 2 | 2 | "use strict"; | |
| 3 | 3 | export default function (text) { | |
| 4 | - return function (req, res, next) { | ||
| 5 | - res.end(text + "\n"); | ||
| 4 | + return function (req, res) { | ||
| 5 | + res.end(text); | ||
| 6 | 6 | }; | |
| 7 | 7 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,19 +1,26 @@ | |||
| 1 | 1 | // LICENSE : MIT | |
| 2 | 2 | "use strict"; | |
| 3 | - var assert = require("power-assert"); | ||
| 3 | + import assert from "power-assert"; | ||
| 4 | 4 | import connect from "connect" | |
| 5 | 5 | import hello from "../../src/connect/hello"; | |
| 6 | - | ||
| 6 | + import http from "http"; | ||
| 7 | + import fetch from "node-fetch"; | ||
| 7 | 8 | describe("hello", function () { | |
| 8 | - before(function () { | ||
| 9 | - var connect = require('connect'); | ||
| 10 | - var http = require('http'); | ||
| 9 | + var responseText = "test"; | ||
| 10 | + var server; | ||
| 11 | + before(function (done) { | ||
| 11 | 12 | var app = connect(); | |
| 12 | - app.use(hello("test")); | ||
| 13 | - http.createServer(app).listen(3000, done); | ||
| 13 | + app.use(hello(responseText)); | ||
| 14 | + server = http.createServer(app).listen(3000, done); | ||
| 14 | 15 | }); | |
| 15 | - after(function (done) { | ||
| 16 | + after(function () { | ||
| 17 | + server.close(); | ||
| 18 | + }); | ||
| 19 | + it("should return response text", function () { | ||
| 20 | + return fetch("http://localhost:3000") | ||
| 21 | + .then(res => res.text()) | ||
| 22 | + .then(text => { | ||
| 23 | + assert.equal(text, | ||
| 24 | + }); | ||
| 16 | 25 | }); | |
| 17 | - it("should return test", function () | ||
| 18 | - ); | ||
| 19 | 26 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments