mirror of
https://github.com/socketio/socket.io.git
synced 2026-04-30 03:00:39 -04:00
Merge pull request #2496 from nus-fboa2016-si/compat-test
Added test for compat version transformed by babel
This commit is contained in:
@@ -10,6 +10,14 @@ node_js:
|
||||
git:
|
||||
depth: 1
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- node_js: '0.10'
|
||||
env: TEST_VERSION=compat
|
||||
- node_js: '0.12'
|
||||
env: TEST_VERSION=compat
|
||||
- node_js: '4'
|
||||
env: TEST_VERSION=compat
|
||||
#matrix:
|
||||
#fast_finish: true
|
||||
#allow_failures:
|
||||
|
||||
11
Readme.md
11
Readme.md
@@ -422,6 +422,17 @@ To see the output from all of Socket.IO's debugging scopes you can use:
|
||||
DEBUG=socket.io* node myapp
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
```
|
||||
npm test
|
||||
```
|
||||
This runs the `gulp` task `test`. By default the test will be run with the source code in `lib` directory.
|
||||
|
||||
Set the environmental variable `TEST_VERSION` to `compat` to test the transpiled es5-compat version of the code.
|
||||
|
||||
The `gulp` task `test` will always transpile the source code into es5 and export to `dist` first before running the test.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
||||
16
gulpfile.js
16
gulpfile.js
@@ -22,14 +22,15 @@ gulp.task('clean', function () {
|
||||
return del([TRANSPILE_DEST_DIR]);
|
||||
})
|
||||
|
||||
gulp.task('test', function(){
|
||||
gulp.task('test', ['transpile'], function(){
|
||||
return gulp.src('test/socket.io.js', {read: false})
|
||||
.pipe(mocha({
|
||||
slow: 200,
|
||||
reporter: 'dot',
|
||||
reporter: 'spec',
|
||||
bail: true
|
||||
}))
|
||||
.once('error', function () {
|
||||
.once('error', function (err) {
|
||||
console.error(err.stack);
|
||||
process.exit(1);
|
||||
})
|
||||
.once('end', function () {
|
||||
@@ -37,6 +38,12 @@ gulp.task('test', function(){
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('set-compat-node-env', function() {
|
||||
process.env.TEST_VERSION = 'compat';
|
||||
});
|
||||
|
||||
gulp.task('test-compat', ['set-compat-node-env', 'test']);
|
||||
|
||||
gulp.task('istanbul-pre-test', function () {
|
||||
return gulp.src(['lib/**/*.js'])
|
||||
// Covering files
|
||||
@@ -51,7 +58,8 @@ gulp.task('test-cov', ['istanbul-pre-test'], function(){
|
||||
reporter: 'dot'
|
||||
}))
|
||||
.pipe(istanbul.writeReports())
|
||||
.once('error', function (){
|
||||
.once('error', function (err){
|
||||
console.error(err.stack);
|
||||
process.exit(1);
|
||||
})
|
||||
.once('end', function (){
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
|
||||
var testVersion = process.env.TEST_VERSION;
|
||||
var http = require('http').Server;
|
||||
var io = require('..');
|
||||
var io;
|
||||
if (testVersion === 'compat') {
|
||||
console.log('testing compat version');
|
||||
io = require('../dist');
|
||||
} else {
|
||||
io = require('../lib');
|
||||
}
|
||||
var fs = require('fs');
|
||||
var join = require('path').join;
|
||||
var exec = require('child_process').exec;
|
||||
@@ -426,9 +432,18 @@ describe('socket.io', function(){
|
||||
});
|
||||
|
||||
describe('namespaces', function(){
|
||||
var Socket = require('../lib/socket');
|
||||
var Namespace = require('../lib/namespace');
|
||||
|
||||
var Socket;
|
||||
if (testVersion === 'compat') {
|
||||
Socket = require('../dist/socket');
|
||||
} else {
|
||||
Socket = require('../lib/socket');
|
||||
}
|
||||
var Namespace;
|
||||
if (testVersion === 'compat') {
|
||||
Namespace = require('../dist/namespace');
|
||||
} else {
|
||||
Namespace = require('../lib/namespace');
|
||||
}
|
||||
it('should be accessible through .sockets', function(){
|
||||
var sio = io();
|
||||
expect(sio.sockets).to.be.a(Namespace);
|
||||
@@ -651,7 +666,7 @@ describe('socket.io', function(){
|
||||
var clientSocket2 = client(srv);
|
||||
sio.on('connection', function() {
|
||||
connections++;
|
||||
if(connections === 2) {
|
||||
if (connections === 2) {
|
||||
done();
|
||||
}
|
||||
});
|
||||
@@ -2036,7 +2051,12 @@ describe('socket.io', function(){
|
||||
});
|
||||
|
||||
describe('middleware', function(done){
|
||||
var Socket = require('../lib/socket');
|
||||
var Socket;
|
||||
if (testVersion === 'compat') {
|
||||
Socket = require('../dist/socket');
|
||||
} else {
|
||||
Socket = require('../lib/socket');
|
||||
}
|
||||
|
||||
it('should call functions', function(done){
|
||||
var srv = http();
|
||||
|
||||
Reference in New Issue
Block a user