Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
hublot
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yoann HOUPERT
hublot
Commits
e43a7748
Commit
e43a7748
authored
Oct 30, 2017
by
Yoann HOUPERT
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add server disconnect function
parent
ed8dc251
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
1 deletion
+34
-1
lib/controller.js
lib/controller.js
+9
-0
lib/controller.test.js
lib/controller.test.js
+25
-1
No files found.
lib/controller.js
View file @
e43a7748
...
...
@@ -36,6 +36,15 @@ const create = (runner, modules, config) => {
room
,
config
.
client
);
return
controller
.
registry
[
room
];
},
forceDisconnect
:
room
=>
{
controller
.
registry
[
room
].
execute
(()
=>
{
/* eslint-disable no-undef */
robot
.
stop
();
/* eslint-enable */
}).
end
();
delete
controller
.
registry
[
room
];
}
};
return
controller
;
...
...
lib/controller.test.js
View file @
e43a7748
...
...
@@ -24,8 +24,19 @@ const {create} = require('./controller.js');
// Here are some needed mocks
const
functionRunnerMock
=
{
execute
()
{
return
{
end
()
{
}
};
}
};
const
runnerMock
=
{
run
:
()
=>
{}
run
:
()
=>
{
return
functionRunnerMock
;
}
};
const
configMock
=
{
...
...
@@ -60,4 +71,17 @@ describe('controller', () => {
controller
.
client
(
'
test
'
);
expect
(
controller
.
registry
).
toHaveProperty
(
'
test
'
,
client1
);
});
test
(
'
should not have any room in registry when the client is disconnect
'
,
()
=>
{
controller
.
client
(
'
test
'
);
controller
.
forceDisconnect
(
'
test
'
);
expect
(
controller
.
registry
).
toEqual
({});
});
test
(
'
should have a room in registry when one client disconnect
'
,
()
=>
{
controller
.
client
(
'
test1
'
);
const
client2
=
controller
.
client
(
'
test2
'
);
controller
.
forceDisconnect
(
'
test1
'
);
expect
(
controller
.
registry
).
toHaveProperty
(
'
test2
'
,
client2
);
});
});
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