Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio_mebibou
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Alexandra Rogova
jio_mebibou
Commits
101fd0ba
Commit
101fd0ba
authored
Mar 09, 2019
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[test] Make it more readable by using promise
parent
b53e74be
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
38 deletions
+23
-38
test/jio/util.js
test/jio/util.js
+23
-38
No files found.
test/jio/util.js
View file @
101fd0ba
...
@@ -17,15 +17,15 @@
...
@@ -17,15 +17,15 @@
* See COPYING file for full licensing terms.
* See COPYING file for full licensing terms.
* See https://www.nexedi.com/licensing for rationale and options.
* See https://www.nexedi.com/licensing for rationale and options.
*/
*/
/*global setTimeout*/
(
function
(
jIO
,
QUnit
)
{
(
function
(
jIO
,
QUnit
,
setTimeout
)
{
"
use strict
"
;
"
use strict
"
;
var
test
=
QUnit
.
test
,
var
test
=
QUnit
.
test
,
equal
=
QUnit
.
equal
,
equal
=
QUnit
.
equal
,
stop
=
QUnit
.
stop
,
stop
=
QUnit
.
stop
,
start
=
QUnit
.
start
,
start
=
QUnit
.
start
,
expect
=
QUnit
.
expect
,
expect
=
QUnit
.
expect
,
module
=
QUnit
.
module
;
module
=
QUnit
.
module
,
ok
=
QUnit
.
ok
;
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// util.stringify
// util.stringify
...
@@ -55,44 +55,29 @@
...
@@ -55,44 +55,29 @@
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// util.ajax
// util.ajax
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
module
(
"
util.ajax
"
,
{
module
(
"
util.ajax
"
);
setup
:
function
()
{
var
context
=
this
;
this
.
jioerror
=
jIO
.
util
.
jIOError
;
this
.
error_spy
=
{};
function
fakejIOError
(
message
,
status_code
)
{
context
.
error_spy
.
message
=
message
;
context
.
error_spy
.
status_code
=
status_code
;
}
fakejIOError
.
prototype
=
new
Error
();
fakejIOError
.
prototype
.
constructor
=
fakejIOError
;
jIO
.
util
.
jIOError
=
fakejIOError
;
},
teardown
:
function
()
{
jIO
.
util
.
jIOError
=
this
.
jioerror
;
}
});
test
(
"
ajax timeout
"
,
function
()
{
test
(
"
ajax timeout
"
,
function
()
{
var
timeout
=
1
,
var
timeout
=
1
;
context
=
this
;
stop
();
stop
();
expect
(
2
);
expect
(
3
);
jIO
.
util
.
ajax
({
type
:
'
GET
'
,
url
:
"
//www.foo/com/bar
"
,
timeout
:
timeout
});
setTimeout
(
function
()
{
start
();
equal
(
context
.
error_spy
.
message
,
"
Gateway Timeout
"
);
equal
(
context
.
error_spy
.
status_code
,
504
);
},
10
);
return
new
RSVP
.
Queue
()
.
then
(
function
()
{
return
jIO
.
util
.
ajax
({
type
:
'
GET
'
,
url
:
"
https://www.example.org/com/bar
"
,
timeout
:
timeout
});
})
.
fail
(
function
(
error
)
{
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
equal
(
error
.
message
,
"
Gateway Timeout
"
);
equal
(
error
.
status_code
,
504
);
})
.
always
(
function
()
{
start
();
});
});
});
}(
jIO
,
QUnit
,
setTimeout
));
}(
jIO
,
QUnit
));
\ No newline at end of file
\ No newline at end of file
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