提交 7d62fea1 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

Add test units.

上级 7e26698d
......@@ -4,4 +4,4 @@
/worker/cldoc/
/worker/mediasoup-tester.sh
/TODO
/test.js
/run.js
......@@ -13,7 +13,7 @@
"undef": true,
"unused": true,
"strict": true,
"maxparams": 5,
"maxparams": 6,
"maxdepth": 4,
"maxstatements": false,
"maxlen": 200,
......@@ -23,7 +23,7 @@
"browserify": false,
"devel": false,
"jquery": false,
"mocha": true,
"mocha": false,
"node": true,
"shelljs": false,
"worker": false
......
......@@ -4,10 +4,11 @@ const gulp = require('gulp');
const jshint = require('gulp-jshint');
const jscs = require('gulp-jscs');
const stylish = require('gulp-jscs-stylish');
const shell = require('gulp-shell');
gulp.task('lint', () =>
{
let src = [ 'gulpfile.js', 'lib/**/*.js' ];
let src = [ 'gulpfile.js', 'lib/**/*.js', 'test/**/*.js' ];
return gulp.src(src)
.pipe(jshint('.jshintrc'))
......@@ -17,4 +18,16 @@ gulp.task('lint', () =>
.pipe(jshint.reporter('fail'));
});
gulp.task('test', shell.task(
[ 'node_modules/.bin/tap --bail --color --reporter=spec test/test_*.js' ]
));
gulp.task('test-debug', shell.task(
[ 'node_modules/.bin/tap --bail --reporter=tap test/test_*.js' ],
{
env : { DEBUG: '*ERROR* *WARN*' },
verbose : true
}
));
gulp.task('default', gulp.series('lint'));
......@@ -17,7 +17,6 @@
"node": ">=4.0.0"
},
"dependencies": {
"bluebird": "^3.0.6",
"check-types": "^5.1.0",
"clone": "^1.0.2",
"debug": "^2.2.0",
......@@ -30,7 +29,9 @@
"gulp-jscs": "^3.0.2",
"gulp-jscs-stylish": "^1.2.1",
"gulp-jshint": "^2.0.0",
"gulp-shell": "^0.5.1",
"jshint": "^2.8.0",
"jshint-stylish": "^2.0.1"
"jshint-stylish": "^2.0.1",
"tap": "^2.3.3"
}
}
'use strict';
const tap = require('tap');
const mediasoup = require('../');
tap.test('mediasoup.createServer() with no options must succeed', { timeout: 500 }, (t) =>
{
let server = mediasoup.createServer();
server.on('close', (error) =>
{
t.error(error, 'should close gracefully');
t.end();
});
setTimeout(() => server.close(), 100);
});
tap.test('mediasoup.createServer() with no options must succeed', { timeout: 500 }, (t) =>
{
let server = mediasoup.createServer({ logLevel: 'WRONG_VALUE' });
server.on('close', (error) =>
{
t.ok(error, 'should close with error');
t.end();
});
});
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论