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
86dd0f68
Commit
86dd0f68
authored
Aug 11, 2014
by
Xiaowu Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add new test for _start&_end
parent
68c4db2b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
163 additions
and
13 deletions
+163
-13
test/jio.storage/indexeddbstorage.tests.js
test/jio.storage/indexeddbstorage.tests.js
+163
-13
No files found.
test/jio.storage/indexeddbstorage.tests.js
View file @
86dd0f68
/*jslint indent: 2, maxlen: 80, nomen: true */
/*jslint indent: 2, maxlen: 80, nomen: true */
/*global module, test, stop, start, expect, ok, deepEqual, location, sinon,
/*global module, test, stop, start, expect, ok, deepEqual, location, sinon,
davstorage_spec, RSVP, jIO, test_util, dav_storage, btoa, define,
davstorage_spec, RSVP, jIO, test_util, dav_storage, btoa, define,
setTimeout, clearTimeout */
setTimeout, clearTimeout
, indexedDB
*/
// define([module_name], [dependencies], module);
// define([module_name], [dependencies], module);
(
function
(
dependencies
,
module
)
{
(
function
(
dependencies
,
module
)
{
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
'
qunit
'
'
qunit
'
],
function
(
util
,
RSVP
,
jIO
)
{
],
function
(
util
,
RSVP
,
jIO
)
{
"
use strict
"
;
"
use strict
"
;
module
(
"
Indexeddb
Storage
"
);
module
(
"
indexeddb
Storage
"
);
function
success
(
promise
)
{
function
success
(
promise
)
{
return
new
RSVP
.
Promise
(
function
(
resolve
,
notify
)
{
return
new
RSVP
.
Promise
(
function
(
resolve
,
notify
)
{
promise
.
then
(
resolve
,
resolve
,
notify
);
promise
.
then
(
resolve
,
resolve
,
notify
);
...
@@ -27,26 +27,19 @@
...
@@ -27,26 +27,19 @@
});
});
}
}
test
(
"
Scenario
"
,
32
,
function
()
{
test
(
"
Scenario
"
,
46
,
function
()
{
//
indexedDB.deleteDatabase("jio:test");
indexedDB
.
deleteDatabase
(
"
jio:test
"
);
var
server
,
shared
=
{},
jio
=
jIO
.
createJIO
(
var
server
,
shared
=
{},
jio
=
jIO
.
createJIO
(
{
"
type
"
:
"
indexeddb
"
,
{
"
type
"
:
"
indexeddb
"
,
"
database
"
:
"
test
"
"
database
"
:
"
test
"
},
},
{
"
workspace
"
:
{}}
{
"
workspace
"
:
{}}
);
);
stop
();
stop
();
server
=
{
restore
:
function
()
{
server
=
{
restore
:
function
()
{
return
;
return
;
}};
}};
function
postNewDocument
()
{
function
postNewDocument
()
{
return
jio
.
post
({
"
title
"
:
"
Unique ID
"
});
return
jio
.
post
({
"
title
"
:
"
Unique ID
"
});
}
}
...
@@ -378,6 +371,85 @@
...
@@ -378,6 +371,85 @@
});
});
}
}
function
getFirstAttachmentRange1
()
{
return
jio
.
getAttachment
({
"
_id
"
:
"
a
"
,
"
_attachment
"
:
"
aa
"
,
"
_start
"
:
0
});
}
function
getFirstAttachmentRangeTest1
(
answer
)
{
var
blob
=
answer
.
data
;
answer
.
data
=
"
<blob>
"
;
return
jIO
.
util
.
readBlobAsText
(
blob
).
then
(
function
(
e
)
{
deepEqual
(
blob
.
type
,
"
text/plain
"
,
"
Check blob type
"
);
deepEqual
(
e
.
target
.
result
,
"
aab
"
,
"
Check blob text content
"
);
deepEqual
(
answer
,
{
"
attachment
"
:
"
aa
"
,
"
data
"
:
"
<blob>
"
,
"
id
"
:
"
a
"
,
"
method
"
:
"
getAttachment
"
,
"
result
"
:
"
success
"
,
"
status
"
:
200
,
"
statusText
"
:
"
Ok
"
},
"
Get first attachment with range :_start:0, _end:undefined
"
);
},
function
(
err
)
{
deepEqual
(
err
,
"
no error
"
,
"
Check blob text content
"
);
});
}
function
getFirstAttachmentRange2
()
{
return
jio
.
getAttachment
({
"
_id
"
:
"
a
"
,
"
_attachment
"
:
"
aa
"
,
"
_start
"
:
0
,
"
_end
"
:
1
});
}
function
getFirstAttachmentRangeTest2
(
answer
)
{
var
blob
=
answer
.
data
;
answer
.
data
=
"
<blob>
"
;
return
jIO
.
util
.
readBlobAsText
(
blob
).
then
(
function
(
e
)
{
deepEqual
(
blob
.
type
,
"
text/plain
"
,
"
Check blob type
"
);
deepEqual
(
e
.
target
.
result
,
"
a
"
,
"
Check blob text content
"
);
deepEqual
(
answer
,
{
"
attachment
"
:
"
aa
"
,
"
data
"
:
"
<blob>
"
,
"
id
"
:
"
a
"
,
"
method
"
:
"
getAttachment
"
,
"
result
"
:
"
success
"
,
"
status
"
:
200
,
"
statusText
"
:
"
Ok
"
},
"
Get first attachment with range :_start:0, _end:1
"
);
},
function
(
err
)
{
deepEqual
(
err
,
"
no error
"
,
"
Check blob text content
"
);
});
}
function
getFirstAttachmentRange3
()
{
return
jio
.
getAttachment
({
"
_id
"
:
"
a
"
,
"
_attachment
"
:
"
aa
"
,
"
_start
"
:
1
,
"
_end
"
:
3
});
}
function
getFirstAttachmentRangeTest3
(
answer
)
{
var
blob
=
answer
.
data
;
answer
.
data
=
"
<blob>
"
;
return
jIO
.
util
.
readBlobAsText
(
blob
).
then
(
function
(
e
)
{
deepEqual
(
blob
.
type
,
"
text/plain
"
,
"
Check blob type
"
);
deepEqual
(
e
.
target
.
result
,
"
ab
"
,
"
Check blob text content
"
);
deepEqual
(
answer
,
{
"
attachment
"
:
"
aa
"
,
"
data
"
:
"
<blob>
"
,
"
id
"
:
"
a
"
,
"
method
"
:
"
getAttachment
"
,
"
result
"
:
"
success
"
,
"
status
"
:
200
,
"
statusText
"
:
"
Ok
"
},
"
Get first attachment with range :_start:1, _end:3
"
);
},
function
(
err
)
{
deepEqual
(
err
,
"
no error
"
,
"
Check blob text content
"
);
});
}
function
getSecondAttachment
()
{
function
getSecondAttachment
()
{
...
@@ -398,12 +470,84 @@
...
@@ -398,12 +470,84 @@
"
result
"
:
"
success
"
,
"
result
"
:
"
success
"
,
"
status
"
:
200
,
"
status
"
:
200
,
"
statusText
"
:
"
Ok
"
"
statusText
"
:
"
Ok
"
},
"
Get first attachment
"
);
},
"
Get second attachment
"
);
},
function
(
err
)
{
deepEqual
(
err
,
"
no error
"
,
"
Check blob text content
"
);
});
}
function
getSecondAttachmentRange1
()
{
return
success
(
jio
.
getAttachment
({
"
_id
"
:
"
a
"
,
"
_attachment
"
:
"
ab
"
,
"
_start
"
:
-
1
}));
}
function
getSecondAttachmentRangeTest1
(
answer
)
{
deepEqual
(
answer
,
{
"
attachment
"
:
"
ab
"
,
"
error
"
:
"
not_found
"
,
"
id
"
:
"
a
"
,
"
message
"
:
"
_start and _end must be positive
"
,
"
method
"
:
"
getAttachment
"
,
"
reason
"
:
"
invalide _start, _end
"
,
"
result
"
:
"
error
"
,
"
status
"
:
404
,
"
statusText
"
:
"
Not Found
"
},
"
get attachment with _start or _end negative -> 404 Not Found
"
);
}
function
getSecondAttachmentRange2
()
{
return
success
(
jio
.
getAttachment
({
"
_id
"
:
"
a
"
,
"
_attachment
"
:
"
ab
"
,
"
_start
"
:
1
,
"
_end
"
:
0
}));
}
function
getSecondAttachmentRangeTest2
(
answer
)
{
deepEqual
(
answer
,
{
"
attachment
"
:
"
ab
"
,
"
error
"
:
"
not_found
"
,
"
id
"
:
"
a
"
,
"
message
"
:
"
start is great then end
"
,
"
method
"
:
"
getAttachment
"
,
"
reason
"
:
"
invalide offset
"
,
"
result
"
:
"
error
"
,
"
status
"
:
404
,
"
statusText
"
:
"
Not Found
"
},
"
get attachment with _start > _end -> 404 Not Found
"
);
}
function
getSecondAttachmentRange3
()
{
return
jio
.
getAttachment
({
"
_id
"
:
"
a
"
,
"
_attachment
"
:
"
ab
"
,
"
_start
"
:
1
,
"
_end
"
:
2
});
}
function
getSecondAttachmentRangeTest3
(
answer
)
{
var
blob
=
answer
.
data
;
answer
.
data
=
"
<blob>
"
;
return
jIO
.
util
.
readBlobAsText
(
blob
).
then
(
function
(
e
)
{
deepEqual
(
blob
.
type
,
"
text/plain
"
,
"
Check blob type
"
);
deepEqual
(
e
.
target
.
result
,
"
b
"
,
"
Check blob text content
"
);
deepEqual
(
answer
,
{
"
attachment
"
:
"
ab
"
,
"
data
"
:
"
<blob>
"
,
"
id
"
:
"
a
"
,
"
method
"
:
"
getAttachment
"
,
"
result
"
:
"
success
"
,
"
status
"
:
200
,
"
statusText
"
:
"
Ok
"
},
"
Get second attachment with range :_start:1, _end:3
"
);
},
function
(
err
)
{
},
function
(
err
)
{
deepEqual
(
err
,
"
no error
"
,
"
Check blob text content
"
);
deepEqual
(
err
,
"
no error
"
,
"
Check blob text content
"
);
});
});
}
}
function
getLastDocument
()
{
function
getLastDocument
()
{
return
jio
.
get
({
"
_id
"
:
"
a
"
});
return
jio
.
get
({
"
_id
"
:
"
a
"
});
}
}
...
@@ -621,9 +765,15 @@
...
@@ -621,9 +765,15 @@
then
(
updateLastDocument
).
then
(
updateLastDocumentTest
).
then
(
updateLastDocument
).
then
(
updateLastDocumentTest
).
// getA a 200
// getA a 200
then
(
getFirstAttachment
).
then
(
getFirstAttachmentTest
).
then
(
getFirstAttachment
).
then
(
getFirstAttachmentTest
).
then
(
getFirstAttachmentRange1
).
then
(
getFirstAttachmentRangeTest1
).
then
(
getFirstAttachmentRange2
).
then
(
getFirstAttachmentRangeTest2
).
then
(
getFirstAttachmentRange3
).
then
(
getFirstAttachmentRangeTest3
).
// getA b 200
// getA b 200
then
(
getSecondAttachment
).
then
(
getSecondAttachmentTest
).
then
(
getSecondAttachment
).
then
(
getSecondAttachmentTest
).
// get 200
then
(
getSecondAttachmentRange1
).
then
(
getSecondAttachmentRangeTest1
).
then
(
getSecondAttachmentRange2
).
then
(
getSecondAttachmentRangeTest2
).
then
(
getSecondAttachmentRange3
).
then
(
getSecondAttachmentRangeTest3
).
// get 200
then
(
getLastDocument
).
then
(
getLastDocumentTest
).
then
(
getLastDocument
).
then
(
getLastDocumentTest
).
// removeA b 204
// removeA b 204
then
(
removeSecondAttachment
).
then
(
removeSecondAttachmentTest
).
then
(
removeSecondAttachment
).
then
(
removeSecondAttachmentTest
).
...
...
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