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
144ac4d2
Commit
144ac4d2
authored
Oct 23, 2017
by
samy
Browse files
Refactoring archive tests
parent
266bfe3e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
23 deletions
+18
-23
client/lib/archive.js
client/lib/archive.js
+0
-1
client/lib/archive.test.js
client/lib/archive.test.js
+18
-22
No files found.
client/lib/archive.js
View file @
144ac4d2
...
...
@@ -28,7 +28,6 @@ robotLib.archive = function (config) {
const
OpenPaasStore
=
config
.
archive
;
const
xhttp
=
new
XMLHttpRequest
();
if
(
transcript
===
undefined
)
{
console
.
log
(
'
there is no transcription yet!
'
);
return
false
;
}
xhttp
.
open
(
'
POST
'
,
OpenPaasStore
+
'
/summary
'
);
...
...
client/lib/archive.test.js
View file @
144ac4d2
...
...
@@ -28,20 +28,22 @@ const XMLHttpRequestMock = {
return
{};
})
};
const
XMLHttpRequest
=
function
()
{
return
XMLHttpRequestMock
;
};
const
config
=
{
archive
:
'
http://172.17.42.1:8080/api
'
};
describe
(
'
client/lib/archive
'
,
()
=>
{
beforeEach
(()
=>
{
global
.
robotLib
=
robotLib
;
global
.
XMLHttpRequest
=
XMLHttpRequest
;
global
.
XMLHttpRequest
=
function
()
{
return
XMLHttpRequestMock
;
};
/* eslint-disable import/no-unassigned-import */
require
(
'
./archive.js
'
);
/* eslint-enable */
global
.
archive
=
global
.
robotLib
.
archive
(
config
);
});
test
(
'
should define robotLib.archive
'
,
()
=>
{
...
...
@@ -49,27 +51,21 @@ describe('client/lib/archive', () => {
});
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
'
);
const
transcript
=
{};
global
.
archive
.
store
(
transcript
);
expect
(
XMLHttpRequestMock
.
open
).
toHaveBeenCalledWith
(
'
POST
'
,
config
.
archive
+
'
/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
);
test
(
'
should make a REST call with valid transcript
'
,
()
=>
{
const
transcript
=
{};
global
.
archive
.
store
(
transcript
);
expect
(
XMLHttpRequestMock
.
send
).
toHaveBeenCalledWith
(
JSON
.
stringify
(
transcript
));
});
test
(
'
should not make a REST call without transcript
'
,
()
=>
{
const
transcript
=
undefined
;
global
.
archive
.
store
(
transcript
);
expect
(
XMLHttpRequestMock
.
send
).
not
.
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