From f10ade7caa47769b2e586845db24c305a42b8d73 Mon Sep 17 00:00:00 2001 From: Isabella Organ Date: Tue, 3 Nov 2015 10:00:21 -0800 Subject: [PATCH 1/6] server appears to be running, receiving files, and writing each to own unique file --- isabella_organ/.gitignore | 1 + isabella_organ/package.json | 34 +++++++++++++++++++ isabella_organ/tcp_server.js | 28 +++++++++++++++ isabella_organ/test/test.js | 22 ++++++++++++ ...logTue Nov 03 2015 09:53:18 GMT-0800 (PST) | 9 +++++ ...logTue Nov 03 2015 09:54:06 GMT-0800 (PST) | 9 +++++ 6 files changed, 103 insertions(+) create mode 100644 isabella_organ/.gitignore create mode 100644 isabella_organ/package.json create mode 100644 isabella_organ/tcp_server.js create mode 100644 isabella_organ/test/test.js create mode 100644 isabella_organ/uniquefile.logTue Nov 03 2015 09:53:18 GMT-0800 (PST) create mode 100644 isabella_organ/uniquefile.logTue Nov 03 2015 09:54:06 GMT-0800 (PST) diff --git a/isabella_organ/.gitignore b/isabella_organ/.gitignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/isabella_organ/.gitignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/isabella_organ/package.json b/isabella_organ/package.json new file mode 100644 index 0000000..66519c9 --- /dev/null +++ b/isabella_organ/package.json @@ -0,0 +1,34 @@ +{ + "name": "isabella_organ", + "version": "1.0.0", + "description": "TCP Server", + "main": "tcp_server.js", + "directories": { + "test": "test" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/isabellaorgan/create_a_tcp_server.git" + }, + "keywords": [ + "tcp", + "server", + "node", + "superagent" + ], + "author": "isabellaorgan@gmail.com", + "license": "ISC", + "bugs": { + "url": "https://github.com/isabellaorgan/create_a_tcp_server/issues" + }, + "homepage": "https://github.com/isabellaorgan/create_a_tcp_server#readme", + "devDependencies": { + "chai": "^3.4.0", + "mocha": "^2.3.3", + "superagent": "^1.4.0", + "superagent-cli": "^2.0.0" + } +} diff --git a/isabella_organ/tcp_server.js b/isabella_organ/tcp_server.js new file mode 100644 index 0000000..193097e --- /dev/null +++ b/isabella_organ/tcp_server.js @@ -0,0 +1,28 @@ +'use strict'; + +var net = require('net'); +var fs = require('fs'); + + +var server = net.createServer(function(socket) { + socket.on('data', function(data) { + fs.writeFile('uniquefile.log' + new Date().toString(), data.toString(), function(err) { + if (err) return console.log(err); + }); + socket.write('some unique thing'); + console.log('write to file'); + }); + + socket.on('end', function() { + console.log('disconnected'); + socket.end(); + }); +}); + +server.listen('3000', function() { + console.log('server up'); +}); + +server.listen(3000); + + diff --git a/isabella_organ/test/test.js b/isabella_organ/test/test.js new file mode 100644 index 0000000..020ee49 --- /dev/null +++ b/isabella_organ/test/test.js @@ -0,0 +1,22 @@ +var fs = require('fs'); +var net = require('net'); +var request = require('superagent'); +var chai = require('chai'); +var chaiHttp: = require('chai-http'); +chai.use(chaiHttp); +var expect = chai.expect; +var server = require(__dirname + "/../tcp_server.js") + + +describe('tcp server', function() { + it('should receive requests and save them to a file', function(done) { + chai.request('localhost:3000') + .get('/something') + .end(function(err, socket) { + expect(err).to.eql(null); + expect(socet.text).to.eql('some unique thing'); + done(); + }); +}); + + diff --git a/isabella_organ/uniquefile.logTue Nov 03 2015 09:53:18 GMT-0800 (PST) b/isabella_organ/uniquefile.logTue Nov 03 2015 09:53:18 GMT-0800 (PST) new file mode 100644 index 0000000..5eba3b7 --- /dev/null +++ b/isabella_organ/uniquefile.logTue Nov 03 2015 09:53:18 GMT-0800 (PST) @@ -0,0 +1,9 @@ +GET / HTTP/1.1 +Host: localhost:3000 +Connection: keep-alive +Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 +Upgrade-Insecure-Requests: 1 +User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36 +Accept-Encoding: gzip, deflate, sdch +Accept-Language: en-US,en;q=0.8 + diff --git a/isabella_organ/uniquefile.logTue Nov 03 2015 09:54:06 GMT-0800 (PST) b/isabella_organ/uniquefile.logTue Nov 03 2015 09:54:06 GMT-0800 (PST) new file mode 100644 index 0000000..5eba3b7 --- /dev/null +++ b/isabella_organ/uniquefile.logTue Nov 03 2015 09:54:06 GMT-0800 (PST) @@ -0,0 +1,9 @@ +GET / HTTP/1.1 +Host: localhost:3000 +Connection: keep-alive +Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 +Upgrade-Insecure-Requests: 1 +User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36 +Accept-Encoding: gzip, deflate, sdch +Accept-Language: en-US,en;q=0.8 + From c7b8b68262db97aeeec169336b25f78cd2fe68f0 Mon Sep 17 00:00:00 2001 From: Isabella Organ Date: Tue, 3 Nov 2015 10:38:48 -0800 Subject: [PATCH 2/6] add gulpfile and test --- isabella_organ/gulpfile.js | 19 +++++++++++++++++++ isabella_organ/package.json | 2 ++ isabella_organ/test/test.js | 7 ++++--- ...logTue Nov 03 2015 09:53:18 GMT-0800 (PST) | 9 --------- ...logTue Nov 03 2015 09:54:06 GMT-0800 (PST) | 9 --------- 5 files changed, 25 insertions(+), 21 deletions(-) create mode 100644 isabella_organ/gulpfile.js delete mode 100644 isabella_organ/uniquefile.logTue Nov 03 2015 09:53:18 GMT-0800 (PST) delete mode 100644 isabella_organ/uniquefile.logTue Nov 03 2015 09:54:06 GMT-0800 (PST) diff --git a/isabella_organ/gulpfile.js b/isabella_organ/gulpfile.js new file mode 100644 index 0000000..efe6d99 --- /dev/null +++ b/isabella_organ/gulpfile.js @@ -0,0 +1,19 @@ +'use strict' + +var gulp = require('gulp'); +var mocha = require('gulp-mocha'); +var request = require('superagent'); +var chai = require('chai'); +var chaiHttp = require('chai-http'); +var appFiles = ['tcp_server.js']; +var testFiles = ['./test/**/*.js']; + +gulp.task('mochatest', function () { + return gulp.src('test/*.js') + .pipe(mocha({reporter: 'nyan'})); +}); + +gulp.task('default', ['mochatest']); + + + diff --git a/isabella_organ/package.json b/isabella_organ/package.json index 66519c9..62fafaa 100644 --- a/isabella_organ/package.json +++ b/isabella_organ/package.json @@ -27,6 +27,8 @@ "homepage": "https://github.com/isabellaorgan/create_a_tcp_server#readme", "devDependencies": { "chai": "^3.4.0", + "gulp": "^3.9.0", + "gulp-mocha": "^2.1.3", "mocha": "^2.3.3", "superagent": "^1.4.0", "superagent-cli": "^2.0.0" diff --git a/isabella_organ/test/test.js b/isabella_organ/test/test.js index 020ee49..0b8fcb7 100644 --- a/isabella_organ/test/test.js +++ b/isabella_organ/test/test.js @@ -2,10 +2,10 @@ var fs = require('fs'); var net = require('net'); var request = require('superagent'); var chai = require('chai'); -var chaiHttp: = require('chai-http'); +var chaiHttp = require('chai-http'); chai.use(chaiHttp); var expect = chai.expect; -var server = require(__dirname + "/../tcp_server.js") +var server = require(__dirname + "/../tcp_server.js"); describe('tcp server', function() { @@ -14,7 +14,8 @@ describe('tcp server', function() { .get('/something') .end(function(err, socket) { expect(err).to.eql(null); - expect(socet.text).to.eql('some unique thing'); + expect(socket.text).to.eql('some unique thing'); + }); done(); }); }); diff --git a/isabella_organ/uniquefile.logTue Nov 03 2015 09:53:18 GMT-0800 (PST) b/isabella_organ/uniquefile.logTue Nov 03 2015 09:53:18 GMT-0800 (PST) deleted file mode 100644 index 5eba3b7..0000000 --- a/isabella_organ/uniquefile.logTue Nov 03 2015 09:53:18 GMT-0800 (PST) +++ /dev/null @@ -1,9 +0,0 @@ -GET / HTTP/1.1 -Host: localhost:3000 -Connection: keep-alive -Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 -Upgrade-Insecure-Requests: 1 -User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36 -Accept-Encoding: gzip, deflate, sdch -Accept-Language: en-US,en;q=0.8 - diff --git a/isabella_organ/uniquefile.logTue Nov 03 2015 09:54:06 GMT-0800 (PST) b/isabella_organ/uniquefile.logTue Nov 03 2015 09:54:06 GMT-0800 (PST) deleted file mode 100644 index 5eba3b7..0000000 --- a/isabella_organ/uniquefile.logTue Nov 03 2015 09:54:06 GMT-0800 (PST) +++ /dev/null @@ -1,9 +0,0 @@ -GET / HTTP/1.1 -Host: localhost:3000 -Connection: keep-alive -Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 -Upgrade-Insecure-Requests: 1 -User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36 -Accept-Encoding: gzip, deflate, sdch -Accept-Language: en-US,en;q=0.8 - From 7aef2e51109f9345e44074f832daecadb91a4c99 Mon Sep 17 00:00:00 2001 From: Isabella Organ Date: Tue, 3 Nov 2015 10:49:48 -0800 Subject: [PATCH 3/6] finish gulpfile --- isabella_organ/gulpfile.js | 26 ++++++++++++++++++- isabella_organ/package.json | 1 + ...logTue Nov 03 2015 10:40:30 GMT-0800 (PST) | 6 +++++ ...logTue Nov 03 2015 10:42:48 GMT-0800 (PST) | 6 +++++ ...logTue Nov 03 2015 10:45:07 GMT-0800 (PST) | 9 +++++++ 5 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 isabella_organ/uniquefile.logTue Nov 03 2015 10:40:30 GMT-0800 (PST) create mode 100644 isabella_organ/uniquefile.logTue Nov 03 2015 10:42:48 GMT-0800 (PST) create mode 100644 isabella_organ/uniquefile.logTue Nov 03 2015 10:45:07 GMT-0800 (PST) diff --git a/isabella_organ/gulpfile.js b/isabella_organ/gulpfile.js index efe6d99..391ef17 100644 --- a/isabella_organ/gulpfile.js +++ b/isabella_organ/gulpfile.js @@ -2,18 +2,42 @@ var gulp = require('gulp'); var mocha = require('gulp-mocha'); +var jshint = require('gulp-jshint'); var request = require('superagent'); var chai = require('chai'); var chaiHttp = require('chai-http'); var appFiles = ['tcp_server.js']; var testFiles = ['./test/**/*.js']; +gulp.task('jshint:test', function() { + return gulp.src(testFiles) + .pipe(jshint({ + node: true, + globals: { + describe: true, + it: true, + before: true, + after: true + } + })) + .pipe(jshint.reporter('default')); +}); + +gulp.task('jshint:app', function() { + return gulp.src(appFiles) + .pipe(jshint({ + node: true + })) + .pipe(jshint.reporter('default')); +}); + gulp.task('mochatest', function () { return gulp.src('test/*.js') .pipe(mocha({reporter: 'nyan'})); }); -gulp.task('default', ['mochatest']); +gulp.task('jshint', ['jshint:test', 'jshint:app']); +gulp.task('default', ['jshint', 'mochatest']); diff --git a/isabella_organ/package.json b/isabella_organ/package.json index 62fafaa..05ddee1 100644 --- a/isabella_organ/package.json +++ b/isabella_organ/package.json @@ -28,6 +28,7 @@ "devDependencies": { "chai": "^3.4.0", "gulp": "^3.9.0", + "gulp-jshint": "^1.12.0", "gulp-mocha": "^2.1.3", "mocha": "^2.3.3", "superagent": "^1.4.0", diff --git a/isabella_organ/uniquefile.logTue Nov 03 2015 10:40:30 GMT-0800 (PST) b/isabella_organ/uniquefile.logTue Nov 03 2015 10:40:30 GMT-0800 (PST) new file mode 100644 index 0000000..6e71fbd --- /dev/null +++ b/isabella_organ/uniquefile.logTue Nov 03 2015 10:40:30 GMT-0800 (PST) @@ -0,0 +1,6 @@ +GET /something HTTP/1.1 +Host: localhost:3000 +Accept-Encoding: gzip, deflate +User-Agent: node-superagent/0.19.1 +Connection: close + diff --git a/isabella_organ/uniquefile.logTue Nov 03 2015 10:42:48 GMT-0800 (PST) b/isabella_organ/uniquefile.logTue Nov 03 2015 10:42:48 GMT-0800 (PST) new file mode 100644 index 0000000..6e71fbd --- /dev/null +++ b/isabella_organ/uniquefile.logTue Nov 03 2015 10:42:48 GMT-0800 (PST) @@ -0,0 +1,6 @@ +GET /something HTTP/1.1 +Host: localhost:3000 +Accept-Encoding: gzip, deflate +User-Agent: node-superagent/0.19.1 +Connection: close + diff --git a/isabella_organ/uniquefile.logTue Nov 03 2015 10:45:07 GMT-0800 (PST) b/isabella_organ/uniquefile.logTue Nov 03 2015 10:45:07 GMT-0800 (PST) new file mode 100644 index 0000000..5eba3b7 --- /dev/null +++ b/isabella_organ/uniquefile.logTue Nov 03 2015 10:45:07 GMT-0800 (PST) @@ -0,0 +1,9 @@ +GET / HTTP/1.1 +Host: localhost:3000 +Connection: keep-alive +Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 +Upgrade-Insecure-Requests: 1 +User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36 +Accept-Encoding: gzip, deflate, sdch +Accept-Language: en-US,en;q=0.8 + From 94cf3592b77a7127ff6ba23b4bd7f19a3195f774 Mon Sep 17 00:00:00 2001 From: Isabella Organ Date: Tue, 3 Nov 2015 10:58:16 -0800 Subject: [PATCH 4/6] remove redundant code, files --- isabella_organ/tcp_server.js | 1 - ...uniquefile.logTue Nov 03 2015 10:40:30 GMT-0800 (PST) | 6 ------ ...uniquefile.logTue Nov 03 2015 10:42:48 GMT-0800 (PST) | 6 ------ ...uniquefile.logTue Nov 03 2015 10:45:07 GMT-0800 (PST) | 9 --------- 4 files changed, 22 deletions(-) delete mode 100644 isabella_organ/uniquefile.logTue Nov 03 2015 10:40:30 GMT-0800 (PST) delete mode 100644 isabella_organ/uniquefile.logTue Nov 03 2015 10:42:48 GMT-0800 (PST) delete mode 100644 isabella_organ/uniquefile.logTue Nov 03 2015 10:45:07 GMT-0800 (PST) diff --git a/isabella_organ/tcp_server.js b/isabella_organ/tcp_server.js index 193097e..17102c6 100644 --- a/isabella_organ/tcp_server.js +++ b/isabella_organ/tcp_server.js @@ -23,6 +23,5 @@ server.listen('3000', function() { console.log('server up'); }); -server.listen(3000); diff --git a/isabella_organ/uniquefile.logTue Nov 03 2015 10:40:30 GMT-0800 (PST) b/isabella_organ/uniquefile.logTue Nov 03 2015 10:40:30 GMT-0800 (PST) deleted file mode 100644 index 6e71fbd..0000000 --- a/isabella_organ/uniquefile.logTue Nov 03 2015 10:40:30 GMT-0800 (PST) +++ /dev/null @@ -1,6 +0,0 @@ -GET /something HTTP/1.1 -Host: localhost:3000 -Accept-Encoding: gzip, deflate -User-Agent: node-superagent/0.19.1 -Connection: close - diff --git a/isabella_organ/uniquefile.logTue Nov 03 2015 10:42:48 GMT-0800 (PST) b/isabella_organ/uniquefile.logTue Nov 03 2015 10:42:48 GMT-0800 (PST) deleted file mode 100644 index 6e71fbd..0000000 --- a/isabella_organ/uniquefile.logTue Nov 03 2015 10:42:48 GMT-0800 (PST) +++ /dev/null @@ -1,6 +0,0 @@ -GET /something HTTP/1.1 -Host: localhost:3000 -Accept-Encoding: gzip, deflate -User-Agent: node-superagent/0.19.1 -Connection: close - diff --git a/isabella_organ/uniquefile.logTue Nov 03 2015 10:45:07 GMT-0800 (PST) b/isabella_organ/uniquefile.logTue Nov 03 2015 10:45:07 GMT-0800 (PST) deleted file mode 100644 index 5eba3b7..0000000 --- a/isabella_organ/uniquefile.logTue Nov 03 2015 10:45:07 GMT-0800 (PST) +++ /dev/null @@ -1,9 +0,0 @@ -GET / HTTP/1.1 -Host: localhost:3000 -Connection: keep-alive -Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 -Upgrade-Insecure-Requests: 1 -User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36 -Accept-Encoding: gzip, deflate, sdch -Accept-Language: en-US,en;q=0.8 - From 8db2b3673027fddd5568a443ab13bde41113776e Mon Sep 17 00:00:00 2001 From: Isabella Organ Date: Tue, 3 Nov 2015 12:10:16 -0800 Subject: [PATCH 5/6] include some of the unique files --- ...uniquefile.logTue Nov 03 2015 11:17:06 GMT-0800 (PST) | 9 +++++++++ ...uniquefile.logTue Nov 03 2015 12:02:52 GMT-0800 (PST) | 6 ++++++ 2 files changed, 15 insertions(+) create mode 100644 isabella_organ/uniquefile.logTue Nov 03 2015 11:17:06 GMT-0800 (PST) create mode 100644 isabella_organ/uniquefile.logTue Nov 03 2015 12:02:52 GMT-0800 (PST) diff --git a/isabella_organ/uniquefile.logTue Nov 03 2015 11:17:06 GMT-0800 (PST) b/isabella_organ/uniquefile.logTue Nov 03 2015 11:17:06 GMT-0800 (PST) new file mode 100644 index 0000000..5eba3b7 --- /dev/null +++ b/isabella_organ/uniquefile.logTue Nov 03 2015 11:17:06 GMT-0800 (PST) @@ -0,0 +1,9 @@ +GET / HTTP/1.1 +Host: localhost:3000 +Connection: keep-alive +Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 +Upgrade-Insecure-Requests: 1 +User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36 +Accept-Encoding: gzip, deflate, sdch +Accept-Language: en-US,en;q=0.8 + diff --git a/isabella_organ/uniquefile.logTue Nov 03 2015 12:02:52 GMT-0800 (PST) b/isabella_organ/uniquefile.logTue Nov 03 2015 12:02:52 GMT-0800 (PST) new file mode 100644 index 0000000..6e71fbd --- /dev/null +++ b/isabella_organ/uniquefile.logTue Nov 03 2015 12:02:52 GMT-0800 (PST) @@ -0,0 +1,6 @@ +GET /something HTTP/1.1 +Host: localhost:3000 +Accept-Encoding: gzip, deflate +User-Agent: node-superagent/0.19.1 +Connection: close + From 5759ceee8460dfb993891327126581c63b995222 Mon Sep 17 00:00:00 2001 From: Isabella Organ Date: Thu, 21 Apr 2016 14:47:02 -0700 Subject: [PATCH 6/6] update code style --- isabella_organ/gulpfile.js | 13 +++++-------- isabella_organ/tcp_server.js | 13 +++++-------- isabella_organ/test/test.js | 10 ++++------ 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/isabella_organ/gulpfile.js b/isabella_organ/gulpfile.js index 391ef17..32da9de 100644 --- a/isabella_organ/gulpfile.js +++ b/isabella_organ/gulpfile.js @@ -1,4 +1,4 @@ -'use strict' +'use strict'; var gulp = require('gulp'); var mocha = require('gulp-mocha'); @@ -9,7 +9,7 @@ var chaiHttp = require('chai-http'); var appFiles = ['tcp_server.js']; var testFiles = ['./test/**/*.js']; -gulp.task('jshint:test', function() { +gulp.task('jshint:test', () => { return gulp.src(testFiles) .pipe(jshint({ node: true, @@ -23,7 +23,7 @@ gulp.task('jshint:test', function() { .pipe(jshint.reporter('default')); }); -gulp.task('jshint:app', function() { +gulp.task('jshint:app', () => { return gulp.src(appFiles) .pipe(jshint({ node: true @@ -31,13 +31,10 @@ gulp.task('jshint:app', function() { .pipe(jshint.reporter('default')); }); -gulp.task('mochatest', function () { +gulp.task('mochatest', () => { return gulp.src('test/*.js') - .pipe(mocha({reporter: 'nyan'})); + .pipe(mocha({ reporter: 'nyan' })); }); gulp.task('jshint', ['jshint:test', 'jshint:app']); gulp.task('default', ['jshint', 'mochatest']); - - - diff --git a/isabella_organ/tcp_server.js b/isabella_organ/tcp_server.js index 17102c6..11bf903 100644 --- a/isabella_organ/tcp_server.js +++ b/isabella_organ/tcp_server.js @@ -4,24 +4,21 @@ var net = require('net'); var fs = require('fs'); -var server = net.createServer(function(socket) { - socket.on('data', function(data) { - fs.writeFile('uniquefile.log' + new Date().toString(), data.toString(), function(err) { +var server = net.createServer((socket) => { + socket.on('data', (data) => { + fs.writeFile('uniquefile.log' + new Date().toString(), data.toString(), (err) => { if (err) return console.log(err); }); socket.write('some unique thing'); console.log('write to file'); }); - socket.on('end', function() { + socket.on('end', () => { console.log('disconnected'); socket.end(); }); }); -server.listen('3000', function() { +server.listen('3000', () => { console.log('server up'); }); - - - diff --git a/isabella_organ/test/test.js b/isabella_organ/test/test.js index 0b8fcb7..ff48384 100644 --- a/isabella_organ/test/test.js +++ b/isabella_organ/test/test.js @@ -5,19 +5,17 @@ var chai = require('chai'); var chaiHttp = require('chai-http'); chai.use(chaiHttp); var expect = chai.expect; -var server = require(__dirname + "/../tcp_server.js"); +var server = require(__dirname + '/../tcp_server.js'); -describe('tcp server', function() { - it('should receive requests and save them to a file', function(done) { +describe('tcp server', () => { + it('should receive requests and save them to a file', (done) => { chai.request('localhost:3000') .get('/something') - .end(function(err, socket) { + .end((err, socket) => { expect(err).to.eql(null); expect(socket.text).to.eql('some unique thing'); }); done(); }); }); - -