[Test] Express backend
This commit is contained in:
parent
bcc1d15b84
commit
46a61dc45e
14
package.json
14
package.json
@ -13,6 +13,11 @@
|
|||||||
"index.js",
|
"index.js",
|
||||||
"defaultDbOptions.json"
|
"defaultDbOptions.json"
|
||||||
],
|
],
|
||||||
|
"scripts": {
|
||||||
|
"test": "NODE_ENV=test mocha --recursive",
|
||||||
|
"test:watch": "NODE_ENV=test mocha --recursive --watch",
|
||||||
|
"prepublish": "npm run test"
|
||||||
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/zalmoxisus/remotedev-server.git"
|
"url": "https://github.com/zalmoxisus/remotedev-server.git"
|
||||||
@ -21,8 +26,8 @@
|
|||||||
"devtools",
|
"devtools",
|
||||||
"remotedev"
|
"remotedev"
|
||||||
],
|
],
|
||||||
"engines" : {
|
"engines": {
|
||||||
"node" : ">=4.0.0"
|
"node": ">=4.0.0"
|
||||||
},
|
},
|
||||||
"author": "Mihail Diordiev <zalmoxisus@gmail.com> (https://github.com/zalmoxisus)",
|
"author": "Mihail Diordiev <zalmoxisus@gmail.com> (https://github.com/zalmoxisus)",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@ -49,5 +54,10 @@
|
|||||||
"semver": "^5.3.0",
|
"semver": "^5.3.0",
|
||||||
"socketcluster": "^5.0.4",
|
"socketcluster": "^5.0.4",
|
||||||
"sqlite3": "^3.1.8"
|
"sqlite3": "^3.1.8"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"expect": "^1.20.2",
|
||||||
|
"mocha": "^3.2.0",
|
||||||
|
"supertest": "^2.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
40
test/socket.spec.js
Normal file
40
test/socket.spec.js
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
var childProcess = require('child_process');
|
||||||
|
var request = require('supertest');
|
||||||
|
var expect = require('expect');
|
||||||
|
var scClient = require('socketcluster-client');
|
||||||
|
var remotedev = require('../');
|
||||||
|
|
||||||
|
describe('Server', function() {
|
||||||
|
var scServer;
|
||||||
|
this.timeout(5000);
|
||||||
|
before(function(done) {
|
||||||
|
scServer = childProcess.fork(__dirname + '/../bin/remotedev.js');
|
||||||
|
setTimeout(done, 2000);
|
||||||
|
});
|
||||||
|
|
||||||
|
after(function() {
|
||||||
|
if (scServer) {
|
||||||
|
scServer.kill();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Express backend', function() {
|
||||||
|
it('loads main page', function(done) {
|
||||||
|
request('http://localhost:8000')
|
||||||
|
.get('/')
|
||||||
|
.expect('Content-Type', /text\/html/)
|
||||||
|
.expect(200)
|
||||||
|
.expect(function(res) {
|
||||||
|
expect(res.text).toMatch(/<title>RemoteDev<\/title>/);
|
||||||
|
})
|
||||||
|
.end(done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('resolves an inexistent url', function(done) {
|
||||||
|
request('http://localhost:8000/jreerfr/123')
|
||||||
|
.get('/')
|
||||||
|
.expect('Content-Type', /text\/html/)
|
||||||
|
.expect(200, done);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user