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
2a28a04e
Commit
2a28a04e
authored
Nov 10, 2017
by
samy
Browse files
fix PR comments
parent
2e27ff4f
Pipeline
#5139
passed with stage
in 46 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
30 deletions
+21
-30
client/lib/archive.js
client/lib/archive.js
+6
-6
client/lib/archive.test.js
client/lib/archive.test.js
+15
-24
No files found.
client/lib/archive.js
View file @
2a28a04e
...
...
@@ -23,13 +23,13 @@
/* global robotLib:true XMLHttpRequest */
/* exported robotController */
function
check
Transcript
(
user
,
text
,
keywords
)
{
return
((
user
===
undefined
||
user
.
constructor
!==
Array
)
||
text
===
undefined
||
(
keywords
===
undefined
||
keywords
.
constructor
!==
Array
));
function
isValid
Transcript
(
user
s
,
text
,
keywords
)
{
return
!
((
user
s
===
undefined
||
user
s
.
constructor
!==
Array
)
||
text
===
undefined
||
(
keywords
===
undefined
||
keywords
.
constructor
!==
Array
));
}
robotLib
.
archive
=
function
(
config
)
{
return
{
store
(
user
,
text
,
keywords
)
{
if
(
check
Transcript
(
user
,
text
,
keywords
))
{
store
(
user
s
,
text
,
keywords
)
{
if
(
!
isValid
Transcript
(
user
s
,
text
,
keywords
))
{
return
false
;
}
...
...
@@ -39,10 +39,10 @@ robotLib.archive = function (config) {
const
transcript
=
{
text
,
keywords
,
users
:
user
users
};
xhttp
.
send
(
JSON
.
stringify
(
transcript
));
return
xhttp
.
status
===
200
;
return
true
;
}
};
};
client/lib/archive.test.js
View file @
2a28a04e
...
...
@@ -30,14 +30,14 @@ const config = {
let
xhr
;
let
request
;
let
user
;
let
user
s
;
let
text
;
let
keywords
;
describe
(
'
client/lib/archive when status server is valide
'
,
()
=>
{
beforeEach
(()
=>
{
request
=
[];
user
=
[
'
userTest@open-paas.org
'
];
user
s
=
[
'
userTest@open-paas.org
'
];
text
=
'
Transcription Text
'
;
keywords
=
[{
key
:
'
keyTest
'
,
...
...
@@ -67,7 +67,7 @@ describe('client/lib/archive when status server is valide', () => {
});
it
(
'
should make a correct REST call
'
,
()
=>
{
const
result
=
global
.
archive
.
store
(
user
,
text
,
keywords
);
const
result
=
global
.
archive
.
store
(
user
s
,
text
,
keywords
);
expect
(
result
).
toBe
(
true
);
});
...
...
@@ -77,47 +77,38 @@ describe('client/lib/archive when status server is valide', () => {
expect
(
request
[
0
]).
toBe
(
undefined
);
});
it
(
'
should
describe the expected behavior when
user is undefined
'
,
()
=>
{
user
=
undefined
;
const
result
=
global
.
archive
.
store
(
user
,
text
,
keywords
);
it
(
'
should
not make a REST call on store
user
s
is undefined
'
,
()
=>
{
user
s
=
undefined
;
const
result
=
global
.
archive
.
store
(
user
s
,
text
,
keywords
);
expect
(
result
).
toBe
(
false
);
expect
(
request
[
0
]).
toBe
(
undefined
);
});
it
(
'
should
describe the expected behavior when
text is undefined
'
,
()
=>
{
it
(
'
should
not make a REST call on store
text is undefined
'
,
()
=>
{
text
=
undefined
;
const
result
=
global
.
archive
.
store
(
user
,
text
,
keywords
);
const
result
=
global
.
archive
.
store
(
user
s
,
text
,
keywords
);
expect
(
result
).
toBe
(
false
);
expect
(
request
[
0
]).
toBe
(
undefined
);
});
it
(
'
should
describe the expected behavi
or when keywords are undefined
'
,
()
=>
{
it
(
'
should
not make a REST call on st
or
e
when keywords are undefined
'
,
()
=>
{
keywords
=
undefined
;
const
result
=
global
.
archive
.
store
(
user
,
text
,
keywords
);
const
result
=
global
.
archive
.
store
(
user
s
,
text
,
keywords
);
expect
(
result
).
toBe
(
false
);
expect
(
request
[
0
]).
toBe
(
undefined
);
});
it
(
'
should
describe the expected behavi
or when keywords is not an Array
'
,
()
=>
{
it
(
'
should
not make a REST call on st
or
e
when keywords is not an Array
'
,
()
=>
{
keywords
=
'
invalidFormat
'
;
const
result
=
global
.
archive
.
store
(
user
,
text
,
keywords
);
const
result
=
global
.
archive
.
store
(
user
s
,
text
,
keywords
);
expect
(
result
).
toBe
(
false
);
expect
(
request
[
0
]).
toBe
(
undefined
);
});
it
(
'
should
describe the expected behavi
or when user
value
is not an Array
'
,
()
=>
{
user
=
''
;
const
result
=
global
.
archive
.
store
(
user
,
text
,
keywords
);
it
(
'
should
not make a REST call on st
or
e
when user
s
is not an Array
'
,
()
=>
{
user
s
=
''
;
const
result
=
global
.
archive
.
store
(
user
s
,
text
,
keywords
);
expect
(
result
).
toBe
(
false
);
expect
(
request
[
0
]).
toBe
(
undefined
);
});
it
(
'
should not make a REST call on store when the webservice fail
'
,
()
=>
{
xhr
=
sinon
.
useFakeXMLHttpRequest
();
xhr
.
onCreate
=
function
(
req
)
{
req
.
status
=
500
;
};
const
result
=
global
.
archive
.
store
(
user
,
text
,
keywords
);
expect
(
result
).
toBe
(
false
);
});
});
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