提交 5e2ef3f8 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

Add test_server.js

上级 c9c12d75
...@@ -4,26 +4,49 @@ const tap = require('tap'); ...@@ -4,26 +4,49 @@ const tap = require('tap');
const mediasoup = require('../'); const mediasoup = require('../');
tap.test('mediasoup.createServer() with no options must succeed', { timeout: 500 }, (t) => tap.test('mediasoup.createServer() with no options must succeed', { timeout: 1000 }, (t) =>
{ {
let server = mediasoup.createServer(); let server = mediasoup.createServer();
server.on('close', (error) => server.on('close', (error) =>
{ {
t.error(error, 'should close gracefully'); if (!error)
t.end(); t.end();
else
t.fail('should not be closed with error');
}); });
setTimeout(() => server.close(), 100); setTimeout(() => server.close(), 100);
}); });
tap.test('mediasoup.createServer() with no options must succeed', { timeout: 500 }, (t) => tap.test('mediasoup.createServer() with valid options must succeed', { timeout: 1000 }, (t) =>
{
let server = mediasoup.createServer(
{
numWorkers : 1,
logLevel : 'warn'
});
server.on('close', (error) =>
{
if (!error)
t.end();
else
t.fail('should not be closed with error');
});
setTimeout(() => server.close(), 100);
});
tap.test('mediasoup.createServer() with wrong options must fail', { timeout: 1000 }, (t) =>
{ {
let server = mediasoup.createServer({ logLevel: 'WRONG_VALUE' }); let server = mediasoup.createServer({ logLevel: 'WRONG_VALUE' });
server.on('close', (error) => server.on('close', (error) =>
{ {
t.ok(error, 'should close with error'); if (error)
t.end(); t.end();
else
t.fail('should be closed with error');
}); });
}); });
'use strict';
const tap = require('tap');
const mediasoup = require('../');
tap.test('server.updateSettings() with no options must succeed', { timeout: 1000 }, (t) =>
{
let server = mediasoup.createServer();
t.tearDown(() => server.close());
server.updateSettings()
.then(() => t.end())
.catch(() => t.fail('should not fail'));
});
tap.test('server.updateSettings() with valid options must succeed', { timeout: 1000 }, (t) =>
{
let server = mediasoup.createServer();
t.tearDown(() => server.close());
server.updateSettings({ logLevel: 'warn' })
.then(() => t.end())
.catch(() => t.fail('should not fail'));
});
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论