Skip to content

Commit 8f6b720

Browse files
committed
fix(connect): fix hello test
1 parent 4fbcc67 commit 8f6b720

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

src/connect/hello.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// LICENSE : MIT
22
"use strict";
33
export default function (text) {
4-
return function (req, res, next) {
5-
res.end(text + "\n");
4+
return function (req, res) {
5+
res.end(text);
66
};
77
}

test/connect/hello-test.js

+17-10
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
// LICENSE : MIT
22
"use strict";
3-
var assert = require("power-assert");
3+
import assert from "power-assert";
44
import connect from "connect"
55
import hello from "../../src/connect/hello";
6-
6+
import http from "http";
7+
import fetch from "node-fetch";
78
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) {
1112
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);
1415
});
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+
});
1625
});
17-
it("should return test", function ()
18-
);
1926
});

0 commit comments

Comments
 (0)