Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
officejs
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
officejs
Commits
148121db
Commit
148121db
authored
Aug 14, 2012
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update DummyStorages and Jio tests
parent
86851fbe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
329 additions
and
219 deletions
+329
-219
OfficeJS/src/jio.dummystorages.js
OfficeJS/src/jio.dummystorages.js
+149
-94
OfficeJS/test/jiotests.js
OfficeJS/test/jiotests.js
+180
-125
No files found.
OfficeJS/src/jio.dummystorages.js
View file @
148121db
// Adds 3 dummy storages to JIO
// Adds 3 dummy storages to JIO
// type:
// type:
// - dummyallok
// - dummyallok
...
@@ -12,58 +11,79 @@
...
@@ -12,58 +11,79 @@
var
newDummyStorageAllOk
=
function
(
spec
,
my
)
{
var
newDummyStorageAllOk
=
function
(
spec
,
my
)
{
var
that
=
Jio
.
storage
(
spec
,
my
,
'
base
'
);
var
that
=
Jio
.
storage
(
spec
,
my
,
'
base
'
);
that
.
saveDocument
=
function
(
command
)
{
var
super_serialized
=
that
.
serialized
;
// Tells us that the document is saved.
that
.
serialized
=
function
()
{
var
o
=
super_serialized
();
o
.
username
=
spec
.
username
;
return
o
;
};
that
.
post
=
function
(
command
)
{
setTimeout
(
function
()
{
setTimeout
(
function
()
{
that
.
success
();
that
.
success
({
},
100
);
// 100 ms, for jiotests simple job waiting
ok
:
true
,
};
// end saveDocument
id
:
command
.
getDocId
()
});
},
100
);
};
// end post
that
.
loadDocument
=
function
(
command
)
{
that
.
put
=
function
(
command
)
{
// Returns a document object containing all information of the
setTimeout
(
function
()
{
// document and its content.
that
.
success
({
ok
:
true
,
id
:
command
.
getDocId
()
});
},
100
);
// 100 ms, for jiotests simple job waiting
};
// end put
that
.
get
=
function
(
command
)
{
setTimeout
(
function
()
{
setTimeout
(
function
()
{
var
doc
=
{
that
.
success
(
{
'
name
'
:
'
file
'
,
_id
:
command
.
getDocId
()
,
'
content
'
:
'
content
'
,
content
:
'
content
'
,
'
creation_date
'
:
10000
,
_creation_date
:
10000
,
'
last_modified
'
:
15000
};
_last_modified
:
15000
that
.
success
(
doc
);
}
);
},
100
);
},
100
);
};
// end loadDocument
};
// end get
that
.
getDocumentList
=
function
(
command
)
{
// It returns a document array containing all the user documents
// with/but their content.
that
.
allDocs
=
function
(
command
)
{
setTimeout
(
function
()
{
setTimeout
(
function
()
{
var
list
=
[
var
o
=
{
{
'
name
'
:
'
file
'
,
total_rows
:
2
,
'
content
'
:
'
filecontent
'
,
rows
:
[{
'
creation_date
'
:
10000
,
id
:
'
file
'
,
'
last_modified
'
:
15000
},
key
:
'
file
'
,
{
'
name
'
:
'
memo
'
,
value
:
{
'
content
'
:
'
memocontent
'
,
content
:
'
filecontent
'
,
'
creation_date
'
:
20000
,
_creation_date
:
10000
,
'
last_modified
'
:
25000
_last_modified
:
15000
}];
}
},{
id
:
'
memo
'
,
key
:
'
memo
'
,
value
:
{
content
:
'
memocontent
'
,
_creation_date
:
20000
,
_last_modified
:
25000
}
}]
};
if
(
command
.
getOption
(
'
metadata_only
'
))
{
if
(
command
.
getOption
(
'
metadata_only
'
))
{
delete
list
[
0
]
.
content
;
delete
o
.
rows
[
0
].
value
.
content
;
delete
list
[
1
]
.
content
;
delete
o
.
rows
[
1
].
value
.
content
;
}
}
that
.
success
(
list
);
that
.
success
(
o
);
},
100
);
},
100
);
};
// end getDocumentList
};
// end allDocs
that
.
removeDocument
=
function
(
command
)
{
// Remove a document from the storage.
that
.
remove
=
function
(
command
)
{
setTimeout
(
function
()
{
setTimeout
(
function
()
{
that
.
success
();
that
.
success
(
{
ok
:
true
,
id
:
command
.
getDocId
()}
);
},
100
);
},
100
);
};
};
// end remove
return
that
;
return
that
;
},
},
// end Dummy Storage All Ok
// end Dummy Storage All Ok
...
@@ -77,25 +97,31 @@
...
@@ -77,25 +97,31 @@
priv
.
error
=
function
()
{
priv
.
error
=
function
()
{
setTimeout
(
function
()
{
setTimeout
(
function
()
{
that
.
error
({
status
:
0
,
statusText
:
'
Unknown Error
'
,
that
.
error
({
status
:
0
,
statusText
:
'
Unknown Error
'
,
message
:
'
Unknown error.
'
});
error
:
'
unknown_error
'
,
message
:
'
Execution encountred an error.
'
,
reason
:
'
Execution encountred an error
'
});
});
});
};
};
that
.
saveDocument
=
function
(
command
)
{
that
.
post
=
function
(
command
)
{
priv
.
error
();
};
// end post
that
.
put
=
function
(
command
)
{
priv
.
error
();
priv
.
error
();
};
// end
saveDocumen
t
};
// end
pu
t
that
.
loadDocumen
t
=
function
(
command
)
{
that
.
ge
t
=
function
(
command
)
{
priv
.
error
();
priv
.
error
();
};
// end
loadDocumen
t
};
// end
ge
t
that
.
getDocumentList
=
function
(
command
)
{
that
.
allDocs
=
function
(
command
)
{
priv
.
error
();
priv
.
error
();
};
// end
getDocumentList
};
// end
allDocs
that
.
remove
Document
=
function
(
command
)
{
that
.
remove
=
function
(
command
)
{
priv
.
error
();
priv
.
error
();
};
// end remove
Document
};
// end remove
return
that
;
return
that
;
},
},
// end Dummy Storage All Fail
// end Dummy Storage All Fail
...
@@ -106,40 +132,53 @@
...
@@ -106,40 +132,53 @@
newDummyStorageAllNotFound
=
function
(
spec
,
my
)
{
newDummyStorageAllNotFound
=
function
(
spec
,
my
)
{
var
that
=
Jio
.
storage
(
spec
,
my
,
'
base
'
);
var
that
=
Jio
.
storage
(
spec
,
my
,
'
base
'
);
that
.
saveDocument
=
function
(
command
)
{
that
.
post
=
function
(
command
)
{
// Document does not exists yet, create it.
setTimeout
(
function
()
{
setTimeout
(
function
()
{
that
.
success
();
that
.
success
({
ok
:
true
,
id
:
command
.
getDocId
()
});
},
100
);
},
100
);
};
// end
saveDocumen
t
};
// end
pos
t
that
.
loadDocument
=
function
(
command
)
{
that
.
put
=
function
(
command
)
{
// Returns a document object containing nothing.
setTimeout
(
function
()
{
that
.
success
({
ok
:
true
,
id
:
command
.
getDocId
()
});
},
100
);
};
// end put
that
.
get
=
function
(
command
)
{
setTimeout
(
function
()
{
setTimeout
(
function
()
{
that
.
error
({
status
:
404
,
statusText
:
'
Not Found
'
,
that
.
error
({
status
:
404
,
statusText
:
'
Not Found
'
,
message
:
'
Document "
'
+
command
.
getPath
()
+
error
:
'
not_found
'
,
'
" not found.
'
});
message
:
'
Document "
'
+
command
.
getDocId
()
+
'
" not found.
'
,
reason
:
'
Document "
'
+
command
.
getDocId
()
+
'
" not found
'
});
},
100
);
},
100
);
};
// end loadDocument
};
// end get
that
.
getDocumentList
=
function
(
command
)
{
// It returns nothing.
that
.
allDocs
=
function
(
command
)
{
setTimeout
(
function
()
{
setTimeout
(
function
()
{
that
.
error
({
status
:
404
,
statusText
:
'
Not Found
'
,
that
.
error
({
status
:
404
,
statusText
:
'
Not Found
'
,
message
:
'
User list not found.
'
});
error
:
'
not_found
'
,
message
:
'
User list not found.
'
,
reason
:
'
User list not found
'
});
},
100
);
},
100
);
};
// end getDocumentList
};
// end allDocs
that
.
removeDocument
=
function
(
command
)
{
// Remove a document from the storage.
that
.
remove
=
function
(
command
)
{
setTimeout
(
function
()
{
setTimeout
(
function
()
{
that
.
success
();
that
.
success
({
ok
:
true
,
id
:
command
.
getDocId
()
});
},
100
);
},
100
);
};
};
// end remove
return
that
;
return
that
;
},
},
// end Dummy Storage All Not Found
// end Dummy Storage All Not Found
...
@@ -170,7 +209,9 @@
...
@@ -170,7 +209,9 @@
priv
.
Try3OKElseFail
=
function
(
tries
,
if_ok_return
)
{
priv
.
Try3OKElseFail
=
function
(
tries
,
if_ok_return
)
{
if
(
typeof
tries
===
'
undefined
'
)
{
if
(
typeof
tries
===
'
undefined
'
)
{
return
that
.
error
({
status
:
0
,
statusText
:
'
Unknown Error
'
,
return
that
.
error
({
status
:
0
,
statusText
:
'
Unknown Error
'
,
message
:
'
Cannot get tried
'
});
error
:
'
unknown_error
'
,
message
:
'
Cannot get tried.
'
,
reason
:
'
Cannot get tried
'
});
}
}
if
(
tries
<
3
)
{
if
(
tries
<
3
)
{
return
that
.
retry
(
return
that
.
retry
(
...
@@ -180,37 +221,51 @@
...
@@ -180,37 +221,51 @@
return
that
.
success
(
if_ok_return
);
return
that
.
success
(
if_ok_return
);
}
}
if
(
tries
>
3
)
{
if
(
tries
>
3
)
{
return
that
.
error
({
status
:
0
,
statusText
:
'
Too Much Tries
'
,
return
that
.
error
({
status
:
1
,
statusText
:
'
Too Much Tries
'
,
message
:
'
Too much tries.
'
});
error
:
'
too_much_tries
'
,
message
:
'
Too much tries.
'
,
reason
:
'
Too much tries
'
});
}
}
};
};
that
.
saveDocument
=
function
(
command
)
{
that
.
post
=
function
(
command
)
{
priv
.
doJob
(
command
);
priv
.
doJob
(
command
,{
ok
:
true
,
id
:
command
.
getDocId
()});
};
// end saveDocument
};
// end post
that
.
put
=
function
(
command
)
{
priv
.
doJob
(
command
,{
ok
:
true
,
id
:
command
.
getDocId
()});
};
// end put
that
.
loadDocumen
t
=
function
(
command
)
{
that
.
ge
t
=
function
(
command
)
{
priv
.
doJob
(
command
,{
priv
.
doJob
(
command
,{
'
content
'
:
'
content2
'
,
_id
:
command
.
getDocId
()
,
'
name
'
:
'
file
'
,
content
:
'
content
'
+
command
.
getDocId
()
,
'
creation_date
'
:
11000
,
_creation_date
:
11000
,
'
last_modified
'
:
17000
_last_modified
:
17000
});
});
};
// end loadDocument
};
// end get
that
.
getDocumentList
=
function
(
command
)
{
that
.
allDocs
=
function
(
command
)
{
priv
.
doJob
(
command
,[{
'
name
'
:
'
file
'
,
priv
.
doJob
(
command
,{
'
creation_date
'
:
10000
,
total_rows
:
2
,
'
last_modified
'
:
15000
},
rows
:[{
{
'
name
'
:
'
memo
'
,
id
:
'
file
'
,
key
:
'
file
'
,
'
creation_date
'
:
20000
,
value
:{
'
last_modified
'
:
25000
}
_creation_date
:
10000
,
]);
_last_modified
:
15000
};
// end getDocumentList
}
},{
that
.
removeDocument
=
function
(
command
)
{
id
:
'
memo
'
,
key
:
'
memo
'
,
priv
.
doJob
(
command
);
value
:{
};
// end removeDocument
_creation_date
:
20000
,
_last_modified
:
25000
}
}]});
};
// end allDocs
that
.
remove
=
function
(
command
)
{
priv
.
doJob
(
command
,{
ok
:
true
,
id
:
command
.
getDocId
()});
};
// end remove
return
that
;
return
that
;
};
};
...
...
OfficeJS/test/jiotests.js
View file @
148121db
...
@@ -19,14 +19,70 @@
...
@@ -19,14 +19,70 @@
document
.
querySelector
(
'
body
'
).
appendChild
(
d
);
document
.
querySelector
(
'
body
'
).
appendChild
(
d
);
}());
}());
//// end clear jio localstorage
//// end clear jio localstorage
var
base_tick
=
30000
;
//// Tools
var
empty_fun
=
function
(){},
contains
=
function
(
array
,
content
)
{
var
i
;
if
(
typeof
array
!==
'
object
'
)
{
return
undefined
;
}
for
(
i
=
0
;
i
<
array
.
length
||
0
;
i
+=
1
)
{
if
(
array
[
i
]
===
content
)
{
return
true
;
}
}
return
false
;
},
base_tick
=
30000
,
basic_test_function_generator
=
function
(
o
,
res
,
value
,
message
)
{
return
function
(
err
,
val
)
{
var
jobstatus
=
(
err
?
'
fail
'
:
'
done
'
);
switch
(
res
)
{
case
'
status
'
:
err
=
err
||
{};
val
=
err
.
status
;
break
;
case
'
jobstatus
'
:
val
=
jobstatus
;
break
;
case
'
value
'
:
val
=
err
||
val
;
break
;
default
:
return
;
}
deepEqual
(
val
,
value
,
message
);
};
},
basic_spy_function
=
function
(
o
,
res
,
value
,
message
,
fun
)
{
fun
=
fun
||
'
f
'
;
o
[
fun
]
=
basic_test_function_generator
(
o
,
res
,
value
,
message
);
o
.
t
.
spy
(
o
,
fun
);
},
basic_tick_function
=
function
(
o
)
{
var
tick
,
fun
,
i
=
1
;
tick
=
1000
;
fun
=
fun
||
'
f
'
;
if
(
typeof
arguments
[
i
]
===
'
number
'
)
{
tick
=
arguments
[
i
];
i
++
;
}
if
(
typeof
arguments
[
i
]
===
'
string
'
)
{
fun
=
arguments
[
i
];
i
++
;
}
o
.
clock
.
tick
(
tick
);
if
(
!
o
[
fun
].
calledOnce
)
{
if
(
o
[
fun
].
called
)
{
ok
(
false
,
'
too much results (o.
'
+
fun
+
'
)
'
);
}
else
{
ok
(
false
,
'
no response (o.
'
+
fun
+
'
)
'
);
}
}
},
// debug function to show custumized log at the bottom of the page
// debug function to show custumized log at the bottom of the page
var
my_log
=
function
(
html_string
)
{
my_log
=
function
(
html_string
)
{
document
.
querySelector
(
'
div#log
'
).
innerHTML
+=
html_string
+
'
<hr/>
'
;
document
.
querySelector
(
'
div#log
'
).
innerHTML
+=
html_string
+
'
<hr/>
'
;
};
},
var
empty_fun
=
function
(){};
getXML
=
function
(
url
)
{
//// Tools
var
getXML
=
function
(
url
)
{
var
tmp
=
''
;
var
tmp
=
''
;
$
.
ajax
({
'
url
'
:
url
,
async
:
false
,
$
.
ajax
({
'
url
'
:
url
,
async
:
false
,
dataType
:
'
text
'
,
success
:
function
(
xml
){
tmp
=
xml
;}});
dataType
:
'
text
'
,
success
:
function
(
xml
){
tmp
=
xml
;}});
...
@@ -35,7 +91,7 @@ var getXML = function (url) {
...
@@ -35,7 +91,7 @@ var getXML = function (url) {
objectifyDocumentArray
=
function
(
array
)
{
objectifyDocumentArray
=
function
(
array
)
{
var
obj
=
{},
k
;
var
obj
=
{},
k
;
for
(
k
=
0
;
k
<
array
.
length
;
k
+=
1
)
{
for
(
k
=
0
;
k
<
array
.
length
;
k
+=
1
)
{
obj
[
array
[
k
].
name
]
=
array
[
k
];
obj
[
array
[
k
].
id
]
=
array
[
k
];
}
}
return
obj
;
return
obj
;
},
},
...
@@ -147,126 +203,99 @@ test ('All tests', function () {
...
@@ -147,126 +203,99 @@ test ('All tests', function () {
var
o
=
{};
o
.
t
=
this
;
o
.
clock
=
o
.
t
.
sandbox
.
useFakeTimers
();
var
o
=
{};
o
.
t
=
this
;
o
.
clock
=
o
.
t
.
sandbox
.
useFakeTimers
();
o
.
clock
.
tick
(
base_tick
);
o
.
clock
.
tick
(
base_tick
);
o
.
spy
=
function
(
res
,
value
,
message
,
fun
)
{
o
.
spy
=
basic_spy_function
;
fun
=
fun
||
'
f
'
;
o
.
tick
=
basic_tick_function
;
o
[
fun
]
=
function
(
result
)
{
if
(
res
===
'
status
'
)
{
if
(
typeof
result
!==
'
undefined
'
&&
typeof
result
.
status
!==
'
undefined
'
)
{
deepEqual
(
'
fail
'
,
value
,
message
);
}
else
{
deepEqual
(
'
done
'
,
value
,
message
);
}
}
else
{
deepEqual
(
result
,
value
,
message
);
}
};
o
.
t
.
spy
(
o
,
fun
);
};
o
.
tick
=
function
(
tick
,
fun
)
{
fun
=
fun
||
'
f
'
;
o
.
clock
.
tick
(
tick
||
1000
);
if
(
!
o
[
fun
].
calledOnce
)
{
if
(
o
[
fun
].
called
)
{
ok
(
false
,
'
too much results (o.
'
+
fun
+
'
)
'
);
}
else
{
ok
(
false
,
'
no response (o.
'
+
fun
+
'
)
'
);
}
}
};
// All Ok Dummy Storage
// All Ok Dummy Storage
o
.
jio
=
JIO
.
newJio
({
'
type
'
:
'
dummyallok
'
});
o
.
jio
=
JIO
.
newJio
({
'
type
'
:
'
dummyallok
'
});
// save
// save
o
.
spy
(
'
status
'
,
'
done
'
,
'
dummyallok saving
'
);
o
.
spy
(
o
,
'
value
'
,{
ok
:
true
,
id
:
'
file
'
}
,
'
dummyallok saving
'
);
o
.
jio
.
saveDocument
(
'
file
'
,
'
content
'
,{
success
:
o
.
f
,
error
:
o
.
f
}
);
o
.
jio
.
put
({
_id
:
'
file
'
,
content
:
'
content
'
},
o
.
f
);
o
.
tick
();
o
.
tick
(
o
);
// load
// load
o
.
spy
(
'
value
'
,{
name
:
'
file
'
,
content
:
'
content
'
,
last_modified
:
15000
,
o
.
spy
(
o
,
'
value
'
,{
_id
:
'
file
'
,
content
:
'
content
'
,
_
last_modified
:
15000
,
creation_date
:
10000
},
'
dummyallok loading
'
);
_
creation_date
:
10000
},
'
dummyallok loading
'
);
o
.
jio
.
loadDocument
(
'
file
'
,{
success
:
o
.
f
,
error
:
o
.
f
}
);
o
.
jio
.
get
(
'
file
'
,
o
.
f
);
o
.
tick
();
o
.
tick
(
o
);
// remove
// remove
o
.
spy
(
'
status
'
,
'
done
'
,
'
dummyallok removing
'
);
o
.
spy
(
o
,
'
value
'
,{
ok
:
true
,
id
:
"
file
"
}
,
'
dummyallok removing
'
);
o
.
jio
.
remove
Document
(
'
file
'
,{
success
:
o
.
f
,
error
:
o
.
f
}
);
o
.
jio
.
remove
({
_id
:
'
file
'
},
o
.
f
);
o
.
tick
();
o
.
tick
(
o
);
// get list
// get list
o
.
spy
(
'
value
'
,[{
name
:
'
file
'
,
content
:
'
filecontent
'
,
last_modified
:
15000
,
o
.
spy
(
o
,
'
value
'
,{
creation_date
:
10000
},
total_rows
:
2
,
{
name
:
'
memo
'
,
content
:
'
memocontent
'
,
last_modified
:
25000
,
rows
:[{
creation_date
:
20000
}],
'
dummyallok getting list
'
);
id
:
'
file
'
,
key
:
'
file
'
,
o
.
jio
.
getDocumentList
(
'
.
'
,{
success
:
o
.
f
,
error
:
o
.
f
,
metadata_only
:
false
});
value
:{
o
.
tick
();
content
:
'
filecontent
'
,
_last_modified
:
15000
,
_creation_date
:
10000
}
},{
id
:
'
memo
'
,
key
:
'
memo
'
,
value
:{
content
:
'
memocontent
'
,
_last_modified
:
25000
,
_creation_date
:
20000
}
}]
},
'
dummyallok getting list
'
);
o
.
jio
.
allDocs
({
metadata_only
:
false
},
o
.
f
);
o
.
tick
(
o
);
o
.
jio
.
stop
();
o
.
jio
.
stop
();
o
.
jio
=
JIO
.
newJio
({
'
type
'
:
'
dummyallok
'
});
o
.
jio
=
JIO
.
newJio
({
'
type
'
:
'
dummyallok
'
});
// save
// save
o
.
spy
(
'
status
'
,
'
done
'
,
'
dummyallok saving1
'
,
'
f
'
);
o
.
spy
(
o
,
'
value
'
,{
ok
:
true
,
id
:
'
file
'
},
'
dummyallok saving1
'
,
'
f
'
);
o
.
spy
(
'
status
'
,
'
done
'
,
'
dummyallok saving2
'
,
'
f2
'
);
o
.
spy
(
o
,
'
value
'
,{
ok
:
true
,
id
:
'
file2
'
},
'
dummyallok saving2
'
,
'
f2
'
);
o
.
spy
(
'
status
'
,
'
done
'
,
'
dummyallok saving3
'
,
'
f3
'
);
o
.
spy
(
o
,
'
value
'
,{
ok
:
true
,
id
:
'
file3
'
},
'
dummyallok saving3
'
,
'
f3
'
);
o
.
jio
.
saveDocument
(
'
file
'
,
'
content
'
,{
success
:
o
.
f
,
error
:
o
.
f
});
o
.
jio
.
put
({
_id
:
'
file
'
,
content
:
'
content
'
},
o
.
f
);
o
.
jio
.
saveDocument
(
'
file2
'
,
'
content2
'
,{
success
:
o
.
f2
,
error
:
o
.
f2
});
o
.
jio
.
put
({
_id
:
'
file2
'
,
content
:
'
content2
'
},
o
.
f2
);
o
.
jio
.
saveDocument
(
'
file3
'
,
'
content3
'
,{
success
:
o
.
f3
,
error
:
o
.
f3
});
o
.
jio
.
put
({
_id
:
'
file3
'
,
content
:
'
content3
'
},
o
.
f3
);
o
.
tick
(
1000
,
'
f
'
);
o
.
tick
(
o
,
1000
,
'
f
'
);
o
.
tick
(
1
,
'
f2
'
);
o
.
tick
(
o
,
'
f2
'
);
o
.
tick
(
1
,
'
f3
'
);
o
.
tick
(
o
,
'
f3
'
);
// load
o
.
spy
(
'
value
'
,{
name
:
'
file
'
,
content
:
'
content
'
,
last_modified
:
15000
,
creation_date
:
10000
},
'
dummyallok loading
'
);
o
.
jio
.
loadDocument
(
'
file
'
,{
success
:
o
.
f
,
error
:
o
.
f
});
o
.
tick
();
// remove
o
.
spy
(
'
status
'
,
'
done
'
,
'
dummyallok removing
'
);
o
.
jio
.
removeDocument
(
'
file
'
,{
success
:
o
.
f
,
error
:
o
.
f
});
o
.
tick
();
// get list
o
.
spy
(
'
value
'
,[{
name
:
'
file
'
,
content
:
'
filecontent
'
,
last_modified
:
15000
,
creation_date
:
10000
},
{
name
:
'
memo
'
,
content
:
'
memocontent
'
,
last_modified
:
25000
,
creation_date
:
20000
}],
'
dummyallok getting list
'
);
o
.
jio
.
getDocumentList
(
'
.
'
,{
success
:
o
.
f
,
error
:
o
.
f
,
metadata_only
:
false
});
o
.
tick
();
o
.
jio
.
stop
();
o
.
jio
.
stop
();
// All Fail Dummy Storage
// All Fail Dummy Storage
o
.
jio
=
JIO
.
newJio
({
'
type
'
:
'
dummyallfail
'
});
o
.
jio
=
JIO
.
newJio
({
'
type
'
:
'
dummyallfail
'
});
// save
// save
o
.
spy
(
'
status
'
,
'
fail
'
,
'
dummyallfail saving
'
);
o
.
spy
(
o
,
'
status
'
,
0
,
'
dummyallfail saving
'
);
o
.
jio
.
saveDocument
(
'
file
'
,
'
content
'
,{
success
:
o
.
f
,
error
:
o
.
f
}
);
o
.
jio
.
put
({
_id
:
'
file
'
,
content
:
'
content
'
},
o
.
f
);
o
.
tick
();
o
.
tick
(
o
);
// load
// load
o
.
spy
(
'
status
'
,
'
fail
'
,
'
dummyallfail loading
'
);
o
.
spy
(
o
,
'
status
'
,
0
,
'
dummyallfail loading
'
);
o
.
jio
.
loadDocument
(
'
file
'
,{
success
:
o
.
f
,
error
:
o
.
f
}
);
o
.
jio
.
get
(
'
file
'
,
o
.
f
);
o
.
tick
();
o
.
tick
(
o
);
// remove
// remove
o
.
spy
(
'
status
'
,
'
fail
'
,
'
dummyallfail removing
'
);
o
.
spy
(
o
,
'
status
'
,
0
,
'
dummyallfail removing
'
);
o
.
jio
.
remove
Document
(
'
file
'
,{
success
:
o
.
f
,
error
:
o
.
f
}
);
o
.
jio
.
remove
({
_id
:
'
file
'
},
o
.
f
);
o
.
tick
();
o
.
tick
(
o
);
// get list
// get list
o
.
spy
(
'
status
'
,
'
fail
'
,
'
dummyallfail getting list
'
);
o
.
spy
(
o
,
'
status
'
,
0
,
'
dummyallfail getting list
'
);
o
.
jio
.
getDocumentList
(
'
.
'
,{
success
:
o
.
f
,
error
:
o
.
f
}
);
o
.
jio
.
allDocs
(
o
.
f
);
o
.
tick
();
o
.
tick
(
o
);
o
.
jio
.
stop
();
o
.
jio
.
stop
();
// All Not Found Dummy Storage
// All Not Found Dummy Storage
o
.
jio
=
JIO
.
newJio
({
'
type
'
:
'
dummyallnotfound
'
});
o
.
jio
=
JIO
.
newJio
({
'
type
'
:
'
dummyallnotfound
'
});
// save
// save
o
.
spy
(
'
status
'
,
'
done
'
,
'
dummyallnotfound saving
'
);
o
.
spy
(
o
,
'
value
'
,{
ok
:
true
,
id
:
'
file
'
}
,
'
dummyallnotfound saving
'
);
o
.
jio
.
saveDocument
(
'
file
'
,
'
content
'
,{
success
:
o
.
f
,
error
:
o
.
f
}
);
o
.
jio
.
put
({
_id
:
'
file
'
,
content
:
'
content
'
},
o
.
f
);
o
.
tick
();
o
.
tick
(
o
);
// load
// load
o
.
spy
(
'
status
'
,
'
fail
'
,
'
dummyallnotfound loading
'
);
o
.
spy
(
o
,
'
status
'
,
404
,
'
dummyallnotfound loading
'
)
o
.
jio
.
loadDocument
(
'
file
'
,{
success
:
o
.
f
,
error
:
o
.
f
}
);
o
.
jio
.
get
(
'
file
'
,
o
.
f
);
o
.
tick
();
o
.
tick
(
o
);
// remove
// remove
o
.
spy
(
'
status
'
,
'
done
'
,
'
dummyallnotfound removing
'
);
o
.
spy
(
o
,
'
value
'
,{
ok
:
true
,
id
:
'
file
'
}
,
'
dummyallnotfound removing
'
);
o
.
jio
.
remove
Document
(
'
file
'
,{
success
:
o
.
f
,
error
:
o
.
f
}
);
o
.
jio
.
remove
({
_id
:
'
file
'
},
o
.
f
);
o
.
tick
();
o
.
tick
(
o
);
// get list
// get list
o
.
spy
(
'
status
'
,
'
fail
'
,
'
dummyallnotfound getting list
'
);
o
.
spy
(
o
,
'
status
'
,
404
,
'
dummyallnotfound getting list
'
);
o
.
jio
.
getDocumentList
(
'
.
'
,{
success
:
o
.
f
,
error
:
o
.
f
}
);
o
.
jio
.
allDocs
(
o
.
f
);
o
.
tick
();
o
.
tick
(
o
);
o
.
jio
.
stop
();
o
.
jio
.
stop
();
});
});
...
@@ -279,12 +308,14 @@ test ('Simple Job Elimination', function () {
...
@@ -279,12 +308,14 @@ test ('Simple Job Elimination', function () {
o
.
jio
=
JIO
.
newJio
({
type
:
'
dummyallok
'
,
applicationname
:
'
jiotests
'
});
o
.
jio
=
JIO
.
newJio
({
type
:
'
dummyallok
'
,
applicationname
:
'
jiotests
'
});
id
=
o
.
jio
.
getId
();
id
=
o
.
jio
.
getId
();
o
.
jio
.
saveDocument
(
'
file
'
,
'
content
'
,{
success
:
o
.
f1
,
error
:
o
.
f
,
max_retry
:
1
});
o
.
jio
.
put
({
_id
:
'
file
'
,
content
:
'
content
'
},
{
max_retry
:
1
},
o
.
f1
);
ok
(
LocalOrCookieStorage
.
getItem
(
'
jio/job_array/
'
+
id
)[
0
],
ok
(
LocalOrCookieStorage
.
getItem
(
'
jio/job_array/
'
+
id
)[
0
],
'
job creation
'
);
'
job creation
'
);
o
.
jio
.
remove
Document
(
'
file
'
,{
onResponse
:
o
.
f2
,
max_retry
:
1
}
);
o
.
jio
.
remove
({
_id
:
'
file
'
},{
max_retry
:
1
},
o
.
f2
);
o
.
tmp
=
LocalOrCookieStorage
.
getItem
(
'
jio/job_array/
'
+
id
)[
0
];
o
.
tmp
=
LocalOrCookieStorage
.
getItem
(
'
jio/job_array/
'
+
id
)[
0
];
deepEqual
(
o
.
tmp
.
command
.
label
,
'
removeDocument
'
,
'
job elimination
'
);
deepEqual
(
o
.
tmp
.
command
.
label
,
'
remove
'
,
'
job elimination
'
);
o
.
jio
.
stop
();
});
});
test
(
'
Simple Job Replacement
'
,
function
()
{
test
(
'
Simple Job Replacement
'
,
function
()
{
...
@@ -294,12 +325,11 @@ test ('Simple Job Replacement', function () {
...
@@ -294,12 +325,11 @@ test ('Simple Job Replacement', function () {
o
.
clock
=
this
.
sandbox
.
useFakeTimers
();
o
.
clock
=
this
.
sandbox
.
useFakeTimers
();
o
.
clock
.
tick
(
base_tick
);
o
.
clock
.
tick
(
base_tick
);
o
.
id
=
0
;
o
.
id
=
0
;
o
.
f1
=
function
(
result
)
{
o
.
f1
=
function
(
err
,
val
)
{
if
(
typeof
result
!==
'
undefined
'
&&
if
(
err
)
{
typeof
result
.
status
!==
'
undefined
'
)
{
o
.
err
=
err
;
o
.
status
=
'
fail
'
}
else
{
}
else
{
o
.
status
=
'
done
'
o
.
err
=
{
status
:
'
done
'
};
}
}
};
};
this
.
spy
(
o
,
'
f1
'
);
this
.
spy
(
o
,
'
f1
'
);
...
@@ -307,18 +337,43 @@ test ('Simple Job Replacement', function () {
...
@@ -307,18 +337,43 @@ test ('Simple Job Replacement', function () {
o
.
jio
=
JIO
.
newJio
({
type
:
'
dummyallok
'
,
applicationname
:
'
jiotests
'
});
o
.
jio
=
JIO
.
newJio
({
type
:
'
dummyallok
'
,
applicationname
:
'
jiotests
'
});
o
.
id
=
o
.
jio
.
getId
();
o
.
id
=
o
.
jio
.
getId
();
o
.
jio
.
saveDocument
(
'
file
'
,
'
content
'
,{
success
:
o
.
f1
,
error
:
o
.
f1
}
);
o
.
jio
.
put
({
_id
:
'
file
'
,
content
:
'
content
'
},
o
.
f1
);
o
.
clock
.
tick
(
10
);
o
.
clock
.
tick
(
10
);
o
.
jio
.
saveDocument
(
'
file
'
,
'
content
'
,{
success
:
o
.
f2
,
error
:
o
.
f2
}
);
o
.
jio
.
put
({
_id
:
'
file
'
,
content
:
'
content
'
},
o
.
f2
);
deepEqual
(
LocalOrCookieStorage
.
getItem
(
deepEqual
(
LocalOrCookieStorage
.
getItem
(
'
jio/job_array/
'
+
o
.
id
)[
0
].
date
,
base_tick
+
10
,
'
jio/job_array/
'
+
o
.
id
)[
0
].
date
,
base_tick
+
10
,
'
The first job date have to be equal to the second job date.
'
);
'
The first job date have to be equal to the second job date.
'
);
o
.
clock
.
tick
(
1000
);
o
.
clock
.
tick
(
1000
);
deepEqual
([
o
.
f1
.
calledOnce
,
o
.
status
],[
true
,
'
fail
'
],
deepEqual
([
o
.
f1
.
calledOnce
,
o
.
err
.
status
],[
true
,
12
],
'
callback for the first save request -> result fail
'
);
'
callback for the first save request -> result fail
'
);
ok
(
o
.
f2
.
calledOnce
,
'
second callback is called once
'
);
ok
(
o
.
f2
.
calledOnce
,
'
second callback is called once
'
);
o
.
jio
.
stop
();
o
.
jio
.
stop
();
o
.
jio
=
JIO
.
newJio
({
type
:
'
dummyallok
'
,
applicationname
:
'
jiotests
'
});
o
.
ok1
=
0
;
o
.
jio
.
get
(
'
file1
'
,
function
(
err
,
val
)
{
deepEqual
(
err
||
val
,
{
_id
:
'
file1
'
,
content
:
'
content
'
,
_creation_date
:
10000
,
_last_modified
:
15000
},
'
First load
'
);
o
.
ok1
++
;
});
o
.
ok2
=
0
;
o
.
jio
.
get
(
'
file2
'
,
function
(
err
,
val
)
{
deepEqual
(
err
||
val
,
{
_id
:
'
file2
'
,
content
:
'
content
'
,
_creation_date
:
10000
,
_last_modified
:
15000
},
'
Second load must not replace the first one
'
);
o
.
ok2
++
;
});
o
.
clock
.
tick
(
1000
);
if
(
o
.
ok1
!==
1
)
{
ok
(
false
,
'
no response / too much response
'
);
}
if
(
o
.
ok2
!==
1
)
{
ok
(
false
,
'
no response / too much response
'
);
}
o
.
jio
.
stop
();
});
});
test
(
'
Simple Job Waiting
'
,
function
()
{
test
(
'
Simple Job Waiting
'
,
function
()
{
...
@@ -328,8 +383,8 @@ test ('Simple Job Waiting', function () {
...
@@ -328,8 +383,8 @@ test ('Simple Job Waiting', function () {
o
.
clock
=
this
.
sandbox
.
useFakeTimers
();
o
.
clock
=
this
.
sandbox
.
useFakeTimers
();
o
.
clock
.
tick
(
base_tick
);
o
.
clock
.
tick
(
base_tick
);
o
.
id
=
0
;
o
.
id
=
0
;
o
.
f
=
function
(
result
)
{
o
.
f
=
function
(
err
,
val
)
{
deepEqual
(
result
,
undefined
,
'
job 1 result
'
);
deepEqual
(
err
||
val
,{
ok
:
true
,
id
:
'
file
'
}
,
'
job 1 result
'
);
};
};
o
.
f3
=
o
.
f
;
this
.
spy
(
o
,
'
f3
'
);
o
.
f3
=
o
.
f
;
this
.
spy
(
o
,
'
f3
'
);
o
.
f4
=
o
.
f
;
this
.
spy
(
o
,
'
f4
'
);
o
.
f4
=
o
.
f
;
this
.
spy
(
o
,
'
f4
'
);
...
@@ -347,9 +402,9 @@ test ('Simple Job Waiting', function () {
...
@@ -347,9 +402,9 @@ test ('Simple Job Waiting', function () {
o
.
jio
=
JIO
.
newJio
({
type
:
'
dummyallok
'
,
applicationname
:
'
jiotests
'
});
o
.
jio
=
JIO
.
newJio
({
type
:
'
dummyallok
'
,
applicationname
:
'
jiotests
'
});
o
.
id
=
o
.
jio
.
getId
();
o
.
id
=
o
.
jio
.
getId
();
o
.
jio
.
saveDocument
(
'
file
'
,
'
content
'
,{
success
:
o
.
f3
,
error
:
o
.
f3
}
);
o
.
jio
.
put
({
_id
:
'
file
'
,
content
:
'
content
'
},
o
.
f3
);
o
.
clock
.
tick
(
200
);
o
.
clock
.
tick
(
200
);
o
.
jio
.
saveDocument
(
'
file
'
,
'
content1
'
,{
success
:
o
.
f4
,
error
:
o
.
f4
}
);
o
.
jio
.
put
({
_id
:
'
file
'
,
content
:
'
content1
'
},
o
.
f4
);
o
.
tmp0
=
LocalOrCookieStorage
.
getItem
(
'
jio/job_array/
'
+
o
.
id
)[
0
];
o
.
tmp0
=
LocalOrCookieStorage
.
getItem
(
'
jio/job_array/
'
+
o
.
id
)[
0
];
o
.
tmp1
=
LocalOrCookieStorage
.
getItem
(
'
jio/job_array/
'
+
o
.
id
)[
1
];
o
.
tmp1
=
LocalOrCookieStorage
.
getItem
(
'
jio/job_array/
'
+
o
.
id
)[
1
];
...
@@ -374,16 +429,16 @@ test ('Simple Time Waiting' , function () {
...
@@ -374,16 +429,16 @@ test ('Simple Time Waiting' , function () {
var
o
=
{},
clock
=
this
.
sandbox
.
useFakeTimers
(),
id
=
0
;
var
o
=
{},
clock
=
this
.
sandbox
.
useFakeTimers
(),
id
=
0
;
clock
.
tick
(
base_tick
);
clock
.
tick
(
base_tick
);
o
.
f
=
function
(
result
)
{
o
.
f
=
function
(
err
,
val
)
{
if
(
typeof
result
!==
'
undefined
'
)
{
if
(
err
)
{
o
.
res
=
'
fail
'
;
o
.
res
=
err
;
}
else
{
}
else
{
o
.
res
=
'
done
'
;
o
.
res
=
val
;
}
}
};
};
this
.
spy
(
o
,
'
f
'
);
this
.
spy
(
o
,
'
f
'
);
o
.
jio
=
JIO
.
newJio
({
type
:
'
dummyall3tries
'
,
applicationname
:
'
jiotests
'
});
o
.
jio
=
JIO
.
newJio
({
type
:
'
dummyall3tries
'
,
applicationname
:
'
jiotests
'
});
o
.
jio
.
saveDocument
(
'
file
'
,
'
content
'
,{
success
:
o
.
f
,
error
:
o
.
f
,
max_retry
:
3
}
);
o
.
jio
.
put
({
_id
:
'
file
'
,
content
:
'
content
'
},{
max_retry
:
3
},
o
.
f
);
clock
.
tick
(
10000
);
clock
.
tick
(
10000
);
if
(
!
o
.
f
.
calledOnce
)
{
if
(
!
o
.
f
.
calledOnce
)
{
if
(
o
.
f
.
called
)
{
if
(
o
.
f
.
called
)
{
...
@@ -392,7 +447,7 @@ test ('Simple Time Waiting' , function () {
...
@@ -392,7 +447,7 @@ test ('Simple Time Waiting' , function () {
ok
(
false
,
'
no response.
'
);
ok
(
false
,
'
no response.
'
);
}
}
}
}
deepEqual
(
o
.
res
,
'
done
'
,
'
job done.
'
);
deepEqual
(
o
.
res
,
{
ok
:
true
,
id
:
'
file
'
}
,
'
job done.
'
);
o
.
jio
.
stop
();
o
.
jio
.
stop
();
});
});
...
@@ -401,14 +456,14 @@ module ( 'Jio Restore');
...
@@ -401,14 +456,14 @@ module ( 'Jio Restore');
test
(
'
Restore old Jio
'
,
function
()
{
test
(
'
Restore old Jio
'
,
function
()
{
var
o
=
{};
var
o
=
{};
o
.
clock
=
this
.
sandbox
.
useFakeTimers
();
o
.
clock
=
this
.
sandbox
.
useFakeTimers
();
o
.
f
=
function
(
result
)
{
o
.
f
=
function
()
{
ok
(
false
,
'
must never be called!
'
);
ok
(
false
,
'
must never be called!
'
);
};
};
this
.
spy
(
o
,
'
f
'
);
this
.
spy
(
o
,
'
f
'
);
o
.
jio
=
JIO
.
newJio
({
type
:
'
dummyall3tries
'
,
applicationname
:
'
jiotests
'
});
o
.
jio
=
JIO
.
newJio
({
type
:
'
dummyall3tries
'
,
applicationname
:
'
jiotests
'
});
o
.
id
=
o
.
jio
.
getId
();
o
.
id
=
o
.
jio
.
getId
();
ok
(
true
,
'
create jio, id =
'
+
o
.
id
);
ok
(
true
,
'
create jio, id =
'
+
o
.
id
);
o
.
jio
.
saveDocument
(
'
file
'
,
'
content
'
,{
onResponse
:
o
.
f
,
max_retry
:
3
}
);
o
.
jio
.
put
({
_id
:
'
file
'
,
content
:
'
content
'
},{
max_retry
:
3
},
o
.
f
);
o
.
clock
.
tick
(
1000
);
o
.
clock
.
tick
(
1000
);
o
.
jio
.
close
();
o
.
jio
.
close
();
o
.
jio
=
JIO
.
newJio
({
type
:
'
dummyallok
'
,
applicationname
:
'
jiotests
'
});
o
.
jio
=
JIO
.
newJio
({
type
:
'
dummyallok
'
,
applicationname
:
'
jiotests
'
});
...
@@ -417,9 +472,9 @@ test ('Restore old Jio', function() {
...
@@ -417,9 +472,9 @@ test ('Restore old Jio', function() {
'
job array list must be empty
'
);
'
job array list must be empty
'
);
o
.
tmp1
=
LocalOrCookieStorage
.
getItem
(
'
jio/job_array/
'
+
o
.
jio
.
getId
());
o
.
tmp1
=
LocalOrCookieStorage
.
getItem
(
'
jio/job_array/
'
+
o
.
jio
.
getId
());
if
(
o
.
tmp1
.
length
>
0
)
{
if
(
o
.
tmp1
.
length
>
0
)
{
deepEqual
([
o
.
tmp1
[
0
].
command
.
label
,
o
.
tmp1
[
0
].
command
.
path
,
deepEqual
([
o
.
tmp1
[
0
].
command
.
label
,
o
.
tmp1
[
0
].
command
.
doc
.
_id
,
o
.
tmp1
[
0
].
command
.
content
],
o
.
tmp1
[
0
].
command
.
doc
.
content
],
[
'
saveDocumen
t
'
,
'
file
'
,
'
content
'
],
[
'
pu
t
'
,
'
file
'
,
'
content
'
],
'
job which id is id =
'
+
o
.
jio
.
getId
()
+
'
, restored the jio
'
);
'
job which id is id =
'
+
o
.
jio
.
getId
()
+
'
, restored the jio
'
);
}
else
{
}
else
{
ok
(
false
,
'
The recovered job must exists
'
);
ok
(
false
,
'
The recovered job must exists
'
);
...
...
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