Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio
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
Aurélien Vermylen
jio
Commits
b7a612ea
Commit
b7a612ea
authored
Oct 11, 2017
by
Aurélien Vermylen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add small test for when nothing is returned by API.
parent
fd386848
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
0 deletions
+40
-0
test/jio.storage/automaticapistorage.tests.js
test/jio.storage/automaticapistorage.tests.js
+40
-0
No files found.
test/jio.storage/automaticapistorage.tests.js
View file @
b7a612ea
...
@@ -620,6 +620,46 @@
...
@@ -620,6 +620,46 @@
});
});
});
});
test
(
"
fail nicely when nothing is returned
"
,
function
()
{
var
url
;
this
.
server
.
respond
(
function
(
xhr
)
{
if
(
xhr
.
url
.
indexOf
(
'
https://api.automatic.com/vehicle/
'
)
===
-
1
)
{
return
;
}
if
(
xhr
.
requestHeaders
.
Authorization
&&
xhr
.
requestHeaders
.
Authorization
===
'
Bearer sample_token1
'
)
{
xhr
.
respond
(
200
,
{
"
Content-Type
"
:
"
application/json
"
},
'
{"_metadata":{"count":1,"next":null,"previous":null},
'
+
'
"results":[{"id": "V_example",
'
+
'
"url": "https://api.automatic.com/vehicle/V_example/"}]}
'
);
return
;
}
xhr
.
respond
(
200
,
{
"
Content-Type
"
:
"
application/json
"
},
'
{"_metadata":{"count":0,"next":null,"previous":null},
'
+
'
"results":[]}
'
);
});
url
=
"
https://api.automatic.com/user/me/
"
;
this
.
server
.
respondWith
(
"
GET
"
,
url
,
[
404
,
{
"
Content-Encoding
"
:
"
gzip
"
,
"
Content-Type
"
:
"
application/json
"
},
'
{"detail": "Object not found", "error": "err_object_not_found"}
'
]);
stop
();
expect
(
1
);
this
.
jio
.
buildQuery
({
query
:
'
type:="vehicle"
'
})
.
then
(
function
(
result
)
{
deepEqual
(
result
,
[],
"
Check nothing is returned
"
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
get list of something, check that next url works
"
,
function
()
{
test
(
"
get list of something, check that next url works
"
,
function
()
{
var
url
;
var
url
;
this
.
server
.
respond
(
function
(
xhr
)
{
this
.
server
.
respond
(
function
(
xhr
)
{
...
...
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