Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio-main
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
Hardik Juneja
jio-main
Commits
96d5d045
Commit
96d5d045
authored
Feb 16, 2015
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for LocalStorage
parent
073ebc39
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
247 additions
and
700 deletions
+247
-700
src/jio.storage/localstorage.js
src/jio.storage/localstorage.js
+11
-20
test/jio.storage/localstorage.tests.js
test/jio.storage/localstorage.tests.js
+234
-678
test/tests.html
test/tests.html
+2
-2
No files found.
src/jio.storage/localstorage.js
View file @
96d5d045
...
...
@@ -5,7 +5,7 @@
*/
/*jslint nomen: true */
/*global jIO, localStorage,
window, Blob, Uint8Array
, RSVP */
/*global jIO, localStorage,
Blob
, RSVP */
/**
* JIO Local Storage. Type = 'local'.
...
...
@@ -20,7 +20,7 @@
* @class LocalStorage
*/
(
function
(
jIO
)
{
(
function
(
jIO
,
localStorage
,
Blob
,
RSVP
)
{
"
use strict
"
;
function
LocalStorage
()
{
...
...
@@ -34,47 +34,38 @@
}
}
/**
* Get a document
*
* @method get
* @param {Object} param The given parameters
* @param {Object} options The command options
*/
LocalStorage
.
prototype
.
get
=
function
(
param
)
{
restrictDocumentId
(
param
.
_id
);
var
doc
=
{},
attachments
=
{},
found
=
false
,
key
;
for
(
key
in
localStorage
)
{
if
(
localStorage
.
hasOwnProperty
(
key
))
{
attachments
[
key
]
=
{};
found
=
true
;
}
}
if
(
attachments
.
length
!==
0
)
{
if
(
found
)
{
doc
.
_attachments
=
attachments
;
}
return
doc
;
};
/**
* Get an attachment
*
* @method getAttachment
* @param {Object} param The given parameters
* @param {Object} options The command options
*/
LocalStorage
.
prototype
.
getAttachment
=
function
(
param
)
{
restrictDocumentId
(
param
.
_id
);
var
textstring
=
localStorage
.
getItem
(
param
.
_attachment
);
if
(
textstring
===
null
)
{
throw
new
jIO
.
util
.
jIOError
(
"
Cannot find attachment
"
,
404
);
throw
new
jIO
.
util
.
jIOError
(
"
Cannot find attachment
"
+
param
.
_attachment
,
404
);
}
return
new
Blob
([
textstring
])
;
return
{
data
:
new
Blob
([
textstring
])}
;
};
LocalStorage
.
prototype
.
putAttachment
=
function
(
param
)
{
...
...
@@ -110,4 +101,4 @@
jIO
.
addStorage
(
'
local
'
,
LocalStorage
);
}(
jIO
));
}(
jIO
,
localStorage
,
Blob
,
RSVP
));
test/jio.storage/localstorage.tests.js
View file @
96d5d045
This diff is collapsed.
Click to expand it.
test/tests.html
View file @
96d5d045
...
...
@@ -27,9 +27,9 @@
<script
src=
"jio.storage/memorystorage.tests.js"
></script>
<script
src=
"jio.storage/querystorage.tests.js"
></script>
<script
src=
"jio.storage/localstorage.tests.js"
></script>
<!--script src="jio.storage/localstorage.tests.js"></script>
<script src="jio.storage/davstorage.tests.js"></script>
<!--script src="jio.storage/davstorage.tests.js"></script>
<script src="jio.storage/unionstorage.tests.js"></script>
<script src="jio.storage/querystorage.tests.js"></script-->
...
...
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