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
6cb31064
Commit
6cb31064
authored
Apr 30, 2012
by
Tristan Cavelier
Committed by
Sebastien Robin
May 18, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
QUnit tests are more understandable now.
parent
8fe4ddb3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
79 additions
and
121 deletions
+79
-121
jiotest/jiotests.js
jiotest/jiotests.js
+79
-121
No files found.
jiotest/jiotests.js
View file @
6cb31064
...
@@ -71,7 +71,16 @@ catch (e) {
...
@@ -71,7 +71,16 @@ catch (e) {
}
}
// //// QUnit Tests ////
//// clear jio localstorage
for
(
var
k
in
cookieOrLocal
.
getAll
())
{
var
splitk
=
k
.
split
(
'
/
'
);
if
(
splitk
[
0
]
===
'
jio
'
)
cookieOrLocal
.
deleteItem
(
k
);
}
//// end clear jio localstorage
//// QUnit Tests ////
module
(
'
Jio Global tests
'
);
module
(
'
Jio Global tests
'
);
...
@@ -92,10 +101,8 @@ test ( "Jio simple methods", function () {
...
@@ -92,10 +101,8 @@ test ( "Jio simple methods", function () {
ok
(
JIO
.
addStorageType
(
'
qunit
'
,
function
(){})
,
ok
(
JIO
.
addStorageType
(
'
qunit
'
,
function
(){})
,
"
adding storage type.
"
);
"
adding storage type.
"
);
deepEqual
(
o
.
jio
.
isReady
(),
false
,
'
1 must be not ready
'
);
deepEqual
(
o
.
jio
.
isReady
(),
true
,
'
1 must be not ready
'
);
deepEqual
(
o
.
jio
.
start
(),
true
,
'
1 must be ready now
'
);
o
.
jio2
.
start
();
ok
(
o
.
jio2
.
id
!==
o
.
jio
.
id
,
'
1 and 2 must be different
'
);
ok
(
o
.
jio2
.
id
!==
o
.
jio
.
id
,
'
1 and 2 must be different
'
);
deepEqual
(
o
.
jio
.
stop
(),
true
,
'
1 must be stopped
'
);
deepEqual
(
o
.
jio
.
stop
(),
true
,
'
1 must be stopped
'
);
...
@@ -115,7 +122,6 @@ test ( 'Jio Publish/Sububscribe/Unsubscribe methods', function () {
...
@@ -115,7 +122,6 @@ test ( 'Jio Publish/Sububscribe/Unsubscribe methods', function () {
var
o
=
{};
var
o
=
{};
o
.
jio
=
JIO
.
createNew
();
o
.
jio
=
JIO
.
createNew
();
o
.
jio
.
start
();
var
spy1
=
this
.
spy
();
var
spy1
=
this
.
spy
();
...
@@ -138,41 +144,32 @@ test ('Check name availability', function () {
...
@@ -138,41 +144,32 @@ test ('Check name availability', function () {
// Test if LocalStorage can check the availabality of a name.
// Test if LocalStorage can check the availabality of a name.
// We remove MrCheckName from local storage, and checking must return true.
// We remove MrCheckName from local storage, and checking must return true.
// We now add MrCheckName to local storage, and checking must return false.
// We now add MrCheckName to local storage, and checking must return false.
var
o
=
{}
var
o
=
{};
var
clock
=
this
.
sandbox
.
useFakeTimers
();
var
clock
=
this
.
sandbox
.
useFakeTimers
();
// name must be available
var
t
=
this
;
o
.
f
=
function
(
result
)
{
var
mytest
=
function
(
value
){
deepEqual
(
result
.
isAvailable
,
true
,
o
.
f
=
function
(
result
)
{
'
checking name availabality
'
);
deepEqual
(
result
.
isAvailable
,
value
,
'
checking name availabality
'
);};
var
spy
=
t
.
spy
(
o
,
'
f
'
);
o
.
jio
.
checkNameAvailability
(
{
'
userName
'
:
'
MrCheckName
'
,
'
callback
'
:
o
.
f
});
clock
.
tick
(
510
);
ok
(
o
.
f
.
calledOnce
,
'
callback called once
'
);
};
};
var
spy
=
this
.
spy
(
o
,
'
f
'
);
cookieOrLocal
.
deleteItem
(
'
jio/local/MrCheckName/jiotests/file
'
);
// new jio
o
.
jio
=
JIO
.
createNew
({
'
type
'
:
'
local
'
,
'
userName
'
:
'
noname
'
},
o
.
jio
=
JIO
.
createNew
({
'
type
'
:
'
local
'
,
'
userName
'
:
'
noname
'
},
{
"
ID
"
:
'
noid
'
});
{
"
ID
"
:
'
noid
'
});
o
.
jio
.
start
();
o
.
jio
.
checkNameAvailability
(
// name must be available
{
'
userName
'
:
'
MrCheckName
'
,
'
callback
'
:
o
.
f
});
cookieOrLocal
.
deleteItem
(
'
jio/local/MrCheckName/jiotests/file
'
);
mytest
(
true
);
clock
.
tick
(
510
);
ok
(
o
.
f
.
calledOnce
,
'
callback called once
'
);
// name must be unavailable
// name must not be available
o
.
f2
=
function
(
result
)
{
deepEqual
(
result
.
isAvailable
,
false
,
'
another checking name availabality
'
);
};
var
spy2
=
this
.
spy
(
o
,
'
f2
'
);
cookieOrLocal
.
setItem
(
'
jio/local/MrCheckName/jiotests/file
'
,{});
cookieOrLocal
.
setItem
(
'
jio/local/MrCheckName/jiotests/file
'
,{});
mytest
(
false
);
o
.
jio
.
checkNameAvailability
(
{
'
userName
'
:
'
MrCheckName
'
,
'
callback
'
:
o
.
f2
});
clock
.
tick
(
510
);
ok
(
o
.
f2
.
calledOnce
,
'
another callback called once
'
);
o
.
jio
.
stop
();
o
.
jio
.
stop
();
});
});
...
@@ -181,49 +178,30 @@ test ('Document save', function () {
...
@@ -181,49 +178,30 @@ test ('Document save', function () {
// We launch a saving to localstorage and we check if the file is
// We launch a saving to localstorage and we check if the file is
// realy saved. Then save again and check if
// realy saved. Then save again and check if
var
o
=
{}
var
o
=
{};
var
clock
=
this
.
sandbox
.
useFakeTimers
();
var
t
=
this
;
var
clock
=
this
.
sandbox
.
useFakeTimers
();
var
mytest
=
function
(
value
,
lm
,
cd
){
// save and check document existence
o
.
f
=
function
(
result
)
{
o
.
f
=
function
(
result
)
{
deepEqual
(
result
.
isSaved
,
value
,
'
saving document
'
);};
deepEqual
(
result
.
isSaved
,
true
,
var
spy
=
t
.
spy
(
o
,
'
f
'
);
'
saving document
'
);
o
.
jio
.
saveDocument
(
{
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
,
'
callback
'
:
o
.
f
});
clock
.
tick
(
510
);
ok
(
o
.
f
.
calledOnce
,
'
callback called once
'
);
// check content
var
tmp
=
cookieOrLocal
.
getItem
(
'
jio/local/MrSaveName/jiotests/file
'
);
deepEqual
(
tmp
,{
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
,
'
lastModified
'
:
lm
,
'
creationDate
'
:
cd
},
'
check content
'
);
};
};
var
spy
=
this
.
spy
(
o
,
'
f
'
);
cookieOrLocal
.
deleteItem
(
'
jio/local/MrSaveName/jiotests/file
'
);
clock
.
tick
(
200
);
o
.
jio
=
JIO
.
createNew
({
'
type
'
:
'
local
'
,
'
userName
'
:
'
MrSaveName
'
},
o
.
jio
=
JIO
.
createNew
({
'
type
'
:
'
local
'
,
'
userName
'
:
'
MrSaveName
'
},
{
"
ID
"
:
'
jiotests
'
});
{
"
ID
"
:
'
jiotests
'
});
o
.
jio
.
start
();
cookieOrLocal
.
deleteItem
(
'
jio/local/MrSaveName/jiotests/file
'
);
o
.
jio
.
saveDocument
(
// save and check document existence
{
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
,
'
callback
'
:
o
.
f
});
clock
.
tick
(
200
);
mytest
(
true
,
200
,
200
);
// value, lastmodified, creationdate
clock
.
tick
(
510
);
ok
(
o
.
f
.
calledOnce
,
'
callback called once
'
);
// check content
var
tmp
=
cookieOrLocal
.
getItem
(
'
jio/local/MrSaveName/jiotests/file
'
);
deepEqual
(
tmp
,{
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
,
'
lastModified
'
:
200
,
'
creationDate
'
:
200
},
'
check content
'
);
// re-save and check modification date
// re-save and check modification date
o
.
f2
=
function
(
result
)
{
mytest
(
true
,
710
,
200
);
// 710 = 200 + 510 ms (clock tick)
deepEqual
(
result
.
isSaved
,
true
,
'
saving document again
'
);
};
var
spy2
=
this
.
spy
(
o
,
'
f2
'
);
o
.
jio
.
saveDocument
(
{
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
,
'
callback
'
:
o
.
f2
});
clock
.
tick
(
510
);
ok
(
o
.
f2
.
calledOnce
,
'
another callback called once
'
);
// check content
tmp
=
cookieOrLocal
.
getItem
(
'
jio/local/MrSaveName/jiotests/file
'
);
deepEqual
(
tmp
,{
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
,
'
lastModified
'
:
710
,
'
creationDate
'
:
200
},
'
check content
'
);
o
.
jio
.
stop
();
o
.
jio
.
stop
();
});
});
...
@@ -233,43 +211,27 @@ test ('Document load', function () {
...
@@ -233,43 +211,27 @@ test ('Document load', function () {
// We launch a loading from localstorage and we check if the file is
// We launch a loading from localstorage and we check if the file is
// realy loaded.
// realy loaded.
var
o
=
{}
var
o
=
{};
var
clock
=
this
.
sandbox
.
useFakeTimers
();
var
t
=
this
;
var
clock
=
this
.
sandbox
.
useFakeTimers
();
var
mytest
=
function
(
res
,
value
){
// load a non existing file
o
.
f
=
function
(
result
)
{
o
.
f
=
function
(
result
)
{
deepEqual
(
result
[
res
],
value
,
'
loading document
'
);};
deepEqual
(
result
.
status
,
'
fail
'
,
var
spy
=
t
.
spy
(
o
,
'
f
'
);
'
loading document
'
);
o
.
jio
.
loadDocument
(
{
'
fileName
'
:
'
file
'
,
'
callback
'
:
o
.
f
});
clock
.
tick
(
510
);
ok
(
o
.
f
.
calledOnce
,
'
callback called once
'
);
};
};
var
spy
=
this
.
spy
(
o
,
'
f
'
);
cookieOrLocal
.
deleteItem
(
'
jio/local/MrLoadName/jiotests/file
'
);
o
.
jio
=
JIO
.
createNew
({
'
type
'
:
'
local
'
,
'
userName
'
:
'
MrLoadName
'
},
o
.
jio
=
JIO
.
createNew
({
'
type
'
:
'
local
'
,
'
userName
'
:
'
MrLoadName
'
},
{
"
ID
"
:
'
jiotests
'
});
{
"
ID
"
:
'
jiotests
'
});
o
.
jio
.
start
();
// load a non existing file
o
.
jio
.
loadDocument
(
cookieOrLocal
.
deleteItem
(
'
jio/local/MrLoadName/jiotests/file
'
);
{
'
fileName
'
:
'
file
'
,
'
callback
'
:
o
.
f
});
mytest
(
'
status
'
,
'
fail
'
);
clock
.
tick
(
510
);
ok
(
o
.
f
.
calledOnce
,
'
callback called once
'
);
// re-load file after saving it manually
// re-load file after saving it manually
var
tmp
=
cookieOrLocal
.
setItem
(
'
jio/local/MrLoadName/jiotests/file
'
,
var
doc
=
{
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
,
{
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
,
'
lastModified
'
:
1234
,
'
creationDate
'
:
1000
};
'
lastModified
'
:
1234
,
'
creationDate
'
:
1000
});
cookieOrLocal
.
setItem
(
'
jio/local/MrLoadName/jiotests/file
'
,
doc
);
o
.
f2
=
function
(
result
)
{
mytest
(
'
document
'
,
doc
);
deepEqual
(
result
.
document
,
{
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
,
'
lastModified
'
:
1234
,
'
creationDate
'
:
1000
},
'
loading document again, check content
'
);
};
var
spy2
=
this
.
spy
(
o
,
'
f2
'
);
o
.
jio
.
loadDocument
(
{
'
fileName
'
:
'
file
'
,
'
callback
'
:
o
.
f2
});
clock
.
tick
(
510
);
ok
(
o
.
f2
.
calledOnce
,
'
another callback called once
'
);
o
.
jio
.
stop
();
o
.
jio
.
stop
();
});
});
...
@@ -279,28 +241,24 @@ test ('Document remove', function () {
...
@@ -279,28 +241,24 @@ test ('Document remove', function () {
// We launch a remove from localstorage and we check if the file is
// We launch a remove from localstorage and we check if the file is
// realy removed.
// realy removed.
var
o
=
{}
var
o
=
{};
var
clock
=
this
.
sandbox
.
useFakeTimers
();
var
t
=
this
;
var
clock
=
this
.
sandbox
.
useFakeTimers
();
var
mytest
=
function
(){
o
.
f
=
function
(
result
)
{
o
.
f
=
function
(
result
)
{
deepEqual
(
result
.
isRemoved
,
true
,
'
removing document
'
);};
deepEqual
(
result
.
isRemoved
,
true
,
var
spy
=
t
.
spy
(
o
,
'
f
'
);
'
removing document
'
);
o
.
jio
.
removeDocument
(
{
'
fileName
'
:
'
file
'
,
'
callback
'
:
o
.
f
});
clock
.
tick
(
510
);
ok
(
o
.
f
.
calledOnce
,
'
callback called once
'
);
// check if the file is still there
var
tmp
=
cookieOrLocal
.
getItem
(
'
jio/local/MrRemoveName/jiotests/file
'
);
ok
(
!
tmp
,
'
check no content
'
);
};
};
var
spy
=
this
.
spy
(
o
,
'
f
'
);
cookieOrLocal
.
setItem
(
'
jio/local/MrRemoveName/jiotests/file
'
,{});
o
.
jio
=
JIO
.
createNew
({
'
type
'
:
'
local
'
,
'
userName
'
:
'
MrRemoveName
'
},
o
.
jio
=
JIO
.
createNew
({
'
type
'
:
'
local
'
,
'
userName
'
:
'
MrRemoveName
'
},
{
"
ID
"
:
'
jiotests
'
});
{
"
ID
"
:
'
jiotests
'
});
o
.
jio
.
start
();
// test removing a file
o
.
jio
.
removeDocument
(
cookieOrLocal
.
setItem
(
'
jio/local/MrRemoveName/jiotests/file
'
,{});
{
'
fileName
'
:
'
file
'
,
'
callback
'
:
o
.
f
});
mytest
();
clock
.
tick
(
510
);
ok
(
o
.
f
.
calledOnce
,
'
callback called once
'
);
var
tmp
=
cookieOrLocal
.
getItem
(
'
jio/local/MrRemoveName/jiotests/file
'
);
ok
(
!
tmp
,
'
check no content
'
);
o
.
jio
.
stop
();
o
.
jio
.
stop
();
});
});
...
...
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