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

Add test_room.js and improve test units.

上级 5f961a87
......@@ -13,7 +13,7 @@ tap.test('mediasoup.Server() with no options must succeed', { timeout: 1000 }, (
if (!error)
t.end();
else
t.fail('should not be closed with error');
t.fail(`should not be closed with error: ${error}`);
});
setTimeout(() => server.close(), 100);
......@@ -32,7 +32,7 @@ tap.test('mediasoup.Server() with valid options must succeed', { timeout: 1000 }
if (!error)
t.end();
else
t.fail('should not be closed with error');
t.fail(`should not be closed with error: ${error}`);
});
setTimeout(() => server.close(), 100);
......
'use strict';
const tap = require('tap');
const mediasoup = require('../');
tap.test('room.createPeer() with no options must succeed', { timeout: 1000 }, (t) =>
{
let server = mediasoup.Server();
t.tearDown(() => server.close());
server.createRoom()
.then((room) =>
{
room.createPeer('alice')
.then(() => t.end())
.catch((error) => t.fail(`should not fail: ${error}`));
})
.catch((error) => t.fail(`should not fail: ${error}`));
});
tap.test('room.createPeer() without peerId must fail', { timeout: 1000 }, (t) =>
{
let server = mediasoup.Server();
t.tearDown(() => server.close());
server.createRoom()
.then((room) =>
{
room.createPeer()
.then(() => t.fail('should not succeed'))
.catch(() => t.end());
})
.catch((error) => t.fail(`should not fail: ${error}`));
});
......@@ -11,8 +11,8 @@ tap.test('server.updateSettings() with no options must succeed', { timeout: 1000
t.tearDown(() => server.close());
server.updateSettings()
.then(() => t.end())
.catch(() => t.fail('should not fail'));
.then(() => t.end())
.catch((error) => t.fail(`should not fail: ${error}`));
});
tap.test('server.updateSettings() with valid options must succeed', { timeout: 1000 }, (t) =>
......@@ -22,8 +22,8 @@ tap.test('server.updateSettings() with valid options must succeed', { timeout: 1
t.tearDown(() => server.close());
server.updateSettings({ logLevel: 'warn' })
.then(() => t.end())
.catch(() => t.fail('should not fail'));
.then(() => t.end())
.catch((error) => t.fail(`should not fail: ${error}`));
});
tap.test('server.updateSettings() with invalid options must fail', { timeout: 1000 }, (t) =>
......@@ -59,7 +59,7 @@ tap.test('server.createRoom() with no options must succeed', { timeout: 1000 },
server.createRoom()
.then(() => t.end())
.catch(() => t.fail('should not fail'));
.catch((error) => t.fail(`should not fail: ${error}`));
});
tap.test('server.createRoom() in a closed Server must fail', { timeout: 1000 }, (t) =>
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论