Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
LINAGORA
L
LGS
Labs
hublot
Commits
22e41c18
Commit
22e41c18
authored
Oct 24, 2017
by
Tom Jorquera
Browse files
Fix erroneous test for disconnection
parent
379ddb2c
Pipeline
#4152
passed with stage
in 39 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
8 deletions
+26
-8
client/robot/robot.test.js
client/robot/robot.test.js
+26
-8
No files found.
client/robot/robot.test.js
View file @
22e41c18
...
...
@@ -117,6 +117,13 @@ describe('client/robot without init', () => {
});
describe
(
'
client/robot
'
,
()
=>
{
const
WebRTCAdapterMock
=
{
registeredFunc
:
null
,
addDisconnectCallback
:
f
=>
{
WebRTCAdapterMock
.
registeredFunc
=
f
;
}
};
beforeEach
(()
=>
{
global
.
MediaRecorder
=
function
(
stream
)
{
const
res
=
{
...
...
@@ -162,11 +169,7 @@ describe('client/robot', () => {
disconnect
:
()
=>
{
global
.
isDisconnected
=
true
;
},
getWebRTCAdapter
:
()
=>
({
addDisconnectCallback
:
()
=>
{
global
.
isReconnected
=
true
;
}
})
getWebRTCAdapter
:
()
=>
WebRTCAdapterMock
};
global
.
robotLib
=
{
...
...
@@ -231,9 +234,24 @@ describe('client/robot', () => {
expect
(
global
.
isDisconnected
).
toBe
(
false
);
});
test
(
'
should trigger when robot is disconnect
'
,
()
=>
{
global
.
robotController
.
getWebRTCAdapter
().
addDisconnectCallback
();
expect
(
global
.
isReconnected
).
toBe
(
true
);
test
(
'
should trigger clearCOnnection when robot is disconnected
'
,
()
=>
{
// Mock robot.clearConnection for this test
// Note: since robot is not cleanly reinitialized between each test
// (due to `require` not working as expected), we need to restore
// clearConnection at the end of the test.
let
disconnected
=
false
;
const
oldClearConnection
=
global
.
robot
.
clearConnection
;
global
.
robot
.
clearConnection
=
()
=>
{
disconnected
=
true
;
};
expect
(
WebRTCAdapterMock
.
registeredFunc
).
not
.
toBeNull
();
// Trigger disconnection
WebRTCAdapterMock
.
registeredFunc
();
expect
(
disconnected
).
toBeTruthy
();
// Restore clearConnection
global
.
robot
.
clearConnection
=
oldClearConnection
;
});
test
(
'
should clear the connection
'
,
()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment