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
c22b2eaa
Commit
c22b2eaa
authored
Sep 27, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
localstorage tests updated
parent
345c0cd9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
49 deletions
+49
-49
test/jio.storage/localstorage.tests.js
test/jio.storage/localstorage.tests.js
+49
-49
No files found.
test/jio.storage/localstorage.tests.js
View file @
c22b2eaa
/*jslint indent: 2, maxlen: 80, nomen: true */
/*jslint indent: 2, maxlen: 80, nomen: true */
/*global window, define, module, test_util,
promy
, jIO, local_storage, test, ok,
/*global window, define, module, test_util,
RSVP
, jIO, local_storage, test, ok,
deepEqual, sinon, expect, stop, start, Blob */
deepEqual, sinon, expect, stop, start, Blob */
// define([module_name], [dependencies], module);
// define([module_name], [dependencies], module);
...
@@ -8,14 +8,14 @@
...
@@ -8,14 +8,14 @@
if
(
typeof
define
===
'
function
'
&&
define
.
amd
)
{
if
(
typeof
define
===
'
function
'
&&
define
.
amd
)
{
return
define
(
dependencies
,
module
);
return
define
(
dependencies
,
module
);
}
}
module
(
test_util
,
promy
,
jIO
,
local_storage
);
module
(
test_util
,
RSVP
,
jIO
,
local_storage
);
}([
}([
'
test_util
'
,
'
test_util
'
,
'
promy
'
,
'
rsvp
'
,
'
jio
'
,
'
jio
'
,
'
localstorage
'
,
'
localstorage
'
,
'
qunit
'
'
qunit
'
],
function
(
util
,
promy
,
jIO
,
local_storage
)
{
],
function
(
util
,
RSVP
,
jIO
,
local_storage
)
{
"
use strict
"
;
"
use strict
"
;
module
(
"
LocalStorage
"
);
module
(
"
LocalStorage
"
);
...
@@ -23,18 +23,17 @@
...
@@ -23,18 +23,17 @@
local_storage
.
clear
();
local_storage
.
clear
();
/**
/**
* all(
*
promises): Promise
* all(promises): Promise
*
*
* Produces a promise that is resolved when all the given promises are
* Produces a promise that is resolved when all the given promises are
* fulfilled. The resolved value is an array of each of the answers of the
* fulfilled. The resolved value is an array of each of the answers of the
* given promises.
* given promises.
*
*
* @param {
Promise} *[promises]
The promises to use
* @param {
Array} promises
The promises to use
* @return {Promise} A new promise
* @return {Promise} A new promise
*/
*/
function
all
()
{
function
all
(
promises
)
{
var
promises
,
results
=
[],
i
,
count
=
0
,
deferred
;
var
results
=
[],
i
,
count
=
0
;
promises
=
Array
.
prototype
.
slice
.
call
(
arguments
);
function
cancel
()
{
function
cancel
()
{
var
j
;
var
j
;
for
(
j
=
0
;
j
<
promises
.
length
;
j
+=
1
)
{
for
(
j
=
0
;
j
<
promises
.
length
;
j
+=
1
)
{
...
@@ -43,30 +42,31 @@
...
@@ -43,30 +42,31 @@
}
}
}
}
}
}
deferred
=
new
promy
.
Deferred
(
cancel
);
return
new
RSVP
.
Promise
(
function
(
resolve
,
reject
,
notify
)
{
function
succeed
(
j
)
{
/*jslint unparam: true */
return
function
(
answer
)
{
function
succeed
(
j
)
{
results
[
j
]
=
answer
;
return
function
(
answer
)
{
count
+=
1
;
results
[
j
]
=
answer
;
if
(
count
!==
promises
.
length
)
{
count
+=
1
;
return
;
if
(
count
!==
promises
.
length
)
{
}
return
;
deferred
.
resolve
(
results
);
}
};
resolve
(
results
);
}
};
function
notify
(
j
)
{
}
return
function
(
answer
)
{
function
notified
(
j
)
{
deferred
.
notify
({
return
function
(
answer
)
{
"
promise
"
:
this
,
notify
({
"
index
"
:
j
,
"
promise
"
:
promises
[
j
],
"
answer
"
:
answer
"
index
"
:
j
,
});
"
notified
"
:
answer
};
});
}
};
for
(
i
=
0
;
i
<
promises
.
length
;
i
+=
1
)
{
}
promises
[
i
].
then
(
succeed
(
i
),
succeed
(
i
),
notify
(
i
));
for
(
i
=
0
;
i
<
promises
.
length
;
i
+=
1
)
{
}
promises
[
i
].
then
(
succeed
(
i
),
succeed
(
i
),
notified
(
i
));
return
deferred
.
promise
;
}
},
cancel
);
}
}
test
(
"
Post & Get
"
,
function
()
{
test
(
"
Post & Get
"
,
function
()
{
...
@@ -81,7 +81,7 @@
...
@@ -81,7 +81,7 @@
stop
();
stop
();
all
(
all
(
[
// get inexistent document
// get inexistent document
jio
.
get
({
"
_id
"
:
"
inexistent
"
}).
always
(
function
(
answer
)
{
jio
.
get
({
"
_id
"
:
"
inexistent
"
}).
always
(
function
(
answer
)
{
...
@@ -167,7 +167,7 @@
...
@@ -167,7 +167,7 @@
})
})
).
always
(
start
);
]
).
always
(
start
);
});
});
...
@@ -261,7 +261,7 @@
...
@@ -261,7 +261,7 @@
stop
();
stop
();
all
(
all
(
[
// get an attachment from an inexistent document
// get an attachment from an inexistent document
jio
.
getAttachment
({
jio
.
getAttachment
({
...
@@ -351,10 +351,10 @@
...
@@ -351,10 +351,10 @@
}).
then
(
function
()
{
}).
then
(
function
()
{
// check document and attachment
// check document and attachment
return
all
(
return
all
(
[
jio
.
get
({
"
_id
"
:
"
putattmt1
"
}),
jio
.
get
({
"
_id
"
:
"
putattmt1
"
}),
jio
.
getAttachment
({
"
_id
"
:
"
putattmt1
"
,
"
_attachment
"
:
"
putattmt2
"
})
jio
.
getAttachment
({
"
_id
"
:
"
putattmt1
"
,
"
_attachment
"
:
"
putattmt2
"
})
);
]
);
// XXX check attachment with a getAttachment
// XXX check attachment with a getAttachment
...
@@ -396,7 +396,7 @@
...
@@ -396,7 +396,7 @@
})
})
).
always
(
start
);
]
).
always
(
start
);
});
});
...
@@ -434,10 +434,10 @@
...
@@ -434,10 +434,10 @@
}).
then
(
function
()
{
}).
then
(
function
()
{
// Promise.all always return success
// Promise.all always return success
return
all
(
jio
.
removeAttachment
({
return
all
(
[
jio
.
removeAttachment
({
"
_id
"
:
"
a
"
,
"
_id
"
:
"
a
"
,
"
_attachment
"
:
"
b
"
"
_attachment
"
:
"
b
"
}));
})
]
);
}).
always
(
function
(
answers
)
{
}).
always
(
function
(
answers
)
{
...
@@ -504,7 +504,7 @@
...
@@ -504,7 +504,7 @@
o
.
date_b
=
new
Date
();
o
.
date_b
=
new
Date
();
// put some document before list them
// put some document before list them
all
(
all
(
[
jio
.
put
({
jio
.
put
({
"
_id
"
:
"
a
"
,
"
_id
"
:
"
a
"
,
"
title
"
:
"
one
"
,
"
title
"
:
"
one
"
,
...
@@ -519,7 +519,7 @@
...
@@ -519,7 +519,7 @@
jio
.
put
({
"
_id
"
:
"
b
"
,
"
title
"
:
"
two
"
,
"
date
"
:
o
.
date_a
}),
jio
.
put
({
"
_id
"
:
"
b
"
,
"
title
"
:
"
two
"
,
"
date
"
:
o
.
date_a
}),
jio
.
put
({
"
_id
"
:
"
c
"
,
"
title
"
:
"
one
"
,
"
date
"
:
o
.
date_b
}),
jio
.
put
({
"
_id
"
:
"
c
"
,
"
title
"
:
"
one
"
,
"
date
"
:
o
.
date_b
}),
jio
.
put
({
"
_id
"
:
"
d
"
,
"
title
"
:
"
two
"
,
"
date
"
:
o
.
date_b
})
jio
.
put
({
"
_id
"
:
"
d
"
,
"
title
"
:
"
two
"
,
"
date
"
:
o
.
date_b
})
).
then
(
function
()
{
]
).
then
(
function
()
{
// get a list of documents
// get a list of documents
return
jio
.
allDocs
();
return
jio
.
allDocs
();
...
@@ -699,12 +699,12 @@
...
@@ -699,12 +699,12 @@
);
);
o
.
putCorruptedDocuments
();
o
.
putCorruptedDocuments
();
all
(
all
(
[
jio
.
check
({
"
_id
"
:
"
war
"
}),
jio
.
check
({
"
_id
"
:
"
war
"
}),
jio
.
check
({
"
_id
"
:
"
meta
"
}),
jio
.
check
({
"
_id
"
:
"
meta
"
}),
jio
.
check
({
"
_id
"
:
"
cor
"
}),
jio
.
check
({
"
_id
"
:
"
cor
"
}),
jio
.
check
({
"
_id
"
:
"
inexistent
"
})
jio
.
check
({
"
_id
"
:
"
inexistent
"
})
).
always
(
function
(
answers
)
{
]
).
always
(
function
(
answers
)
{
deepEqual
(
answers
[
0
],
{
deepEqual
(
answers
[
0
],
{
"
error
"
:
"
conflict
"
,
"
error
"
:
"
conflict
"
,
...
@@ -749,12 +749,12 @@
...
@@ -749,12 +749,12 @@
}).
then
(
function
()
{
}).
then
(
function
()
{
return
all
(
return
all
(
[
jio
.
repair
({
"
_id
"
:
"
war
"
}),
jio
.
repair
({
"
_id
"
:
"
war
"
}),
jio
.
repair
({
"
_id
"
:
"
meta
"
}),
jio
.
repair
({
"
_id
"
:
"
meta
"
}),
jio
.
repair
({
"
_id
"
:
"
cor
"
}),
jio
.
repair
({
"
_id
"
:
"
cor
"
}),
jio
.
repair
({
"
_id
"
:
"
inexistent
"
})
jio
.
repair
({
"
_id
"
:
"
inexistent
"
})
);
]
);
}).
always
(
function
(
answers
)
{
}).
always
(
function
(
answers
)
{
...
@@ -793,12 +793,12 @@
...
@@ -793,12 +793,12 @@
}).
then
(
function
()
{
}).
then
(
function
()
{
o
.
getCorruptedDocuments
=
function
()
{
o
.
getCorruptedDocuments
=
function
()
{
return
all
(
return
all
(
[
jio
.
get
({
"
_id
"
:
"
war
"
}),
jio
.
get
({
"
_id
"
:
"
war
"
}),
jio
.
get
({
"
_id
"
:
"
meta
"
}),
jio
.
get
({
"
_id
"
:
"
meta
"
}),
jio
.
get
({
"
_id
"
:
"
cor
"
}),
jio
.
get
({
"
_id
"
:
"
cor
"
}),
jio
.
get
({
"
_id
"
:
"
inexistent
"
})
jio
.
get
({
"
_id
"
:
"
inexistent
"
})
);
]
);
};
};
return
o
.
getCorruptedDocuments
();
return
o
.
getCorruptedDocuments
();
...
...
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