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
266bfe3e
Commit
266bfe3e
authored
Oct 11, 2017
by
samy
Browse files
Implement archive tests
parent
a0b9d8c0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
2 deletions
+42
-2
client/lib/archive.test.js
client/lib/archive.test.js
+42
-2
No files found.
client/lib/archive.test.js
View file @
266bfe3e
...
...
@@ -20,9 +20,24 @@
'
use strict
'
;
describe
(
'
client/lib/stt
'
,
()
=>
{
const
robotLib
=
{};
const
XMLHttpRequestMock
=
{
open
:
jest
.
fn
().
mockImplementation
(()
=>
({})),
setRequestHeader
:
()
=>
{},
send
:
jest
.
fn
().
mockImplementation
(()
=>
{
return
{};
})
};
const
XMLHttpRequest
=
function
()
{
return
XMLHttpRequestMock
;
};
const
config
=
{
archive
:
'
http://172.17.42.1:8080/api
'
};
describe
(
'
client/lib/archive
'
,
()
=>
{
beforeEach
(()
=>
{
global
.
robotLib
=
{};
global
.
robotLib
=
robotLib
;
global
.
XMLHttpRequest
=
XMLHttpRequest
;
/* eslint-disable import/no-unassigned-import */
require
(
'
./archive.js
'
);
...
...
@@ -32,4 +47,29 @@ describe('client/lib/stt', () => {
test
(
'
should define robotLib.archive
'
,
()
=>
{
expect
(
global
.
robotLib
.
archive
).
toBeDefined
();
});
test
(
'
should make correct REST call on store
'
,
()
=>
{
const
transcript
=
'
transcriptTest
'
;
const
OpenPaasStoreTest
=
config
.
archive
;
const
archive
=
global
.
robotLib
.
archive
(
config
);
archive
.
store
(
transcript
);
expect
(
XMLHttpRequestMock
.
open
).
toHaveBeenCalledWith
(
'
POST
'
,
OpenPaasStoreTest
+
'
/summary
'
);
expect
(
XMLHttpRequestMock
.
send
).
toHaveBeenCalled
();
});
test
(
'
should store a correct transcript segment
'
,
()
=>
{
const
archive
=
global
.
robotLib
.
archive
(
config
);
const
transcript
=
{
users
:
[
'
testUser
'
],
text
:
'
test summary text
'
,
keywords
:
[{
key
:
'
testKey
'
,
value
:
'
800
'
}]
};
archive
.
store
(
transcript
);
expect
(
XMLHttpRequestMock
.
send
).
toHaveBeenCalledWith
(
JSON
.
stringify
(
transcript
));
});
});
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