Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Romain Courteaud
jio
Commits
2233e321
Commit
2233e321
authored
Feb 19, 2019
by
preetwinder
Committed by
Romain Courteaud
Apr 19, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for liststorage
parent
a543b514
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
359 additions
and
0 deletions
+359
-0
test/jio.storage/liststorage.tests.js
test/jio.storage/liststorage.tests.js
+357
-0
test/node.js
test/node.js
+1
-0
test/tests.html
test/tests.html
+1
-0
No files found.
test/jio.storage/liststorage.tests.js
0 → 100644
View file @
2233e321
/*
* Copyright 2019, Nexedi SA
*
* This program is free software: you can Use, Study, Modify and Redistribute
* it under the terms of the GNU General Public License version 3, or (at your
* option) any later version, as published by the Free Software Foundation.
*
* You can also Link and Combine this program with other software covered by
* the terms of any of the Free Software licenses or any of the Open Source
* Initiative approved licenses and Convey the resulting work. Corresponding
* source of such a combination shall include the source code for all other
* software used.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See COPYING file for full licensing terms.
* See https://www.nexedi.com/licensing for rationale and options.
*/
/*jslint nomen: true */
/*global Blob*/
(
function
(
jIO
,
QUnit
)
{
"
use strict
"
;
var
test
=
QUnit
.
test
,
stop
=
QUnit
.
stop
,
expect
=
QUnit
.
expect
,
deepEqual
=
QUnit
.
deepEqual
,
ok
=
QUnit
.
ok
,
start
=
QUnit
.
start
,
equal
=
QUnit
.
equal
,
module
=
QUnit
.
module
;
/////////////////////////////////////////////////////////////////
// Custom test substorage definition
/////////////////////////////////////////////////////////////////
function
DummyStorage
()
{
return
this
;
}
jIO
.
addStorage
(
'
dummystorage1
'
,
DummyStorage
);
/////////////////////////////////////////////////////////////////
// ListStorage constructor
/////////////////////////////////////////////////////////////////
module
(
"
ListStorage.constructor
"
);
test
(
"
create storage
"
,
function
()
{
var
jio
=
jIO
.
createJIO
({
type
:
"
list
"
,
sub_storage
:
{
type
:
"
dummystorage1
"
}
});
equal
(
jio
.
__type
,
"
list
"
);
equal
(
jio
.
__storage
.
_sub_storage
.
__type
,
"
dummystorage1
"
);
equal
(
jio
.
__storage
.
_sub_storage_index
.
constructor
.
name
,
"
Set
"
);
});
/////////////////////////////////////////////////////////////////
// ListStorage.get
/////////////////////////////////////////////////////////////////
module
(
"
ListStorage.get
"
);
test
(
"
get called substorage get
"
,
function
()
{
stop
();
expect
(
2
);
var
jio
=
jIO
.
createJIO
({
type
:
"
list
"
,
sub_storage
:
{
type
:
"
dummystorage1
"
}
});
DummyStorage
.
prototype
.
get
=
function
(
id
)
{
equal
(
id
,
"
1
"
);
return
{
"
name
"
:
"
test_name
"
};
};
jio
.
get
(
"
1
"
)
.
then
(
function
(
result
)
{
deepEqual
(
result
,
{
"
name
"
:
"
test_name
"
});
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
/////////////////////////////////////////////////////////////////
// ListStorage.allAttachments
/////////////////////////////////////////////////////////////////
module
(
"
ListStorage.allAttachments
"
);
test
(
"
allAttachments called substorage allAttachments
"
,
function
()
{
stop
();
expect
(
2
);
var
jio
=
jIO
.
createJIO
({
type
:
"
list
"
,
sub_storage
:
{
type
:
"
dummystorage1
"
}
});
DummyStorage
.
prototype
.
allAttachments
=
function
(
id
)
{
equal
(
id
,
"
1
"
);
return
{
attachmentname
:
{}};
};
jio
.
allAttachments
(
"
1
"
)
.
then
(
function
(
result
)
{
deepEqual
(
result
,
{
attachmentname
:
{}
});
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
/////////////////////////////////////////////////////////////////
// ListStorage.post
/////////////////////////////////////////////////////////////////
module
(
"
ListStorage.post
"
);
test
(
"
post called substorage post
"
,
function
()
{
stop
();
expect
(
3
);
var
jio
=
jIO
.
createJIO
({
type
:
"
list
"
,
sub_storage
:
{
type
:
"
dummystorage1
"
}
});
DummyStorage
.
prototype
.
post
=
function
(
param
)
{
deepEqual
(
param
,
{
"
name
"
:
"
test_name
"
});
return
"
posted
"
;
};
jio
.
post
({
"
name
"
:
"
test_name
"
})
.
then
(
function
(
result
)
{
equal
(
result
,
"
posted
"
);
equal
(
jio
.
__storage
.
_sub_storage_index
.
has
(
"
posted
"
),
true
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
/////////////////////////////////////////////////////////////////
// ListStorage.put
/////////////////////////////////////////////////////////////////
module
(
"
ListStorage.put
"
);
test
(
"
put called substorage put
"
,
function
()
{
stop
();
expect
(
4
);
var
jio
=
jIO
.
createJIO
({
type
:
"
list
"
,
sub_storage
:
{
type
:
"
dummystorage1
"
}
});
DummyStorage
.
prototype
.
put
=
function
(
id
,
param
)
{
equal
(
id
,
"
1
"
);
deepEqual
(
param
,
{
"
name
"
:
"
test_name
"
});
return
id
;
};
jio
.
put
(
"
1
"
,
{
"
name
"
:
"
test_name
"
})
.
then
(
function
(
result
)
{
equal
(
result
,
"
1
"
);
equal
(
jio
.
__storage
.
_sub_storage_index
.
has
(
"
1
"
),
true
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
/////////////////////////////////////////////////////////////////
// ListStorage.remove
/////////////////////////////////////////////////////////////////
module
(
"
ListStorage.remove
"
);
test
(
"
remove called substorage remove
"
,
function
()
{
stop
();
expect
(
5
);
var
jio
=
jIO
.
createJIO
({
type
:
"
list
"
,
sub_storage
:
{
type
:
"
dummystorage1
"
}
});
DummyStorage
.
prototype
.
remove
=
function
(
id
)
{
deepEqual
(
id
,
"
1
"
);
return
id
;
};
DummyStorage
.
prototype
.
put
=
function
(
id
)
{
return
id
;
};
jio
.
put
(
"
1
"
,
{
"
name
"
:
"
test_name
"
})
.
then
(
function
(
result
)
{
equal
(
result
,
"
1
"
);
equal
(
jio
.
__storage
.
_sub_storage_index
.
has
(
"
1
"
),
true
);
jio
.
remove
(
"
1
"
)
.
then
(
function
(
result
)
{
equal
(
result
,
"
1
"
);
equal
(
jio
.
__storage
.
_sub_storage_index
.
has
(
"
1
"
),
false
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
});
/////////////////////////////////////////////////////////////////
// ListStorage.getAttachment
/////////////////////////////////////////////////////////////////
module
(
"
ListStorage.getAttachment
"
);
test
(
"
getAttachment called substorage getAttachment
"
,
function
()
{
stop
();
expect
(
3
);
var
jio
=
jIO
.
createJIO
({
type
:
"
list
"
,
sub_storage
:
{
type
:
"
dummystorage1
"
}
}),
blob
=
new
Blob
([
""
]);
DummyStorage
.
prototype
.
getAttachment
=
function
(
id
,
name
)
{
equal
(
id
,
"
1
"
);
equal
(
name
,
"
test_name
"
);
return
blob
;
};
jio
.
getAttachment
(
"
1
"
,
"
test_name
"
)
.
then
(
function
(
result
)
{
equal
(
result
,
blob
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
/////////////////////////////////////////////////////////////////
// ListStorage.putAttachment
/////////////////////////////////////////////////////////////////
module
(
"
ListStorage.putAttachment
"
);
test
(
"
putAttachment called substorage putAttachment
"
,
function
()
{
stop
();
expect
(
4
);
var
jio
=
jIO
.
createJIO
({
type
:
"
list
"
,
sub_storage
:
{
type
:
"
dummystorage1
"
}
}),
blob
=
new
Blob
([
""
]);
DummyStorage
.
prototype
.
putAttachment
=
function
(
id
,
name
,
blob2
)
{
equal
(
id
,
"
1
"
);
equal
(
name
,
"
test_name
"
);
deepEqual
(
blob2
,
blob
);
return
"
OK
"
;
};
jio
.
putAttachment
(
"
1
"
,
"
test_name
"
,
blob
)
.
then
(
function
(
result
)
{
equal
(
result
,
"
OK
"
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
/////////////////////////////////////////////////////////////////
// ListStorage.removeAttachment
/////////////////////////////////////////////////////////////////
module
(
"
ListStorage.removeAttachment
"
);
test
(
"
removeAttachment called substorage removeAttachment
"
,
function
()
{
stop
();
expect
(
3
);
var
jio
=
jIO
.
createJIO
({
type
:
"
list
"
,
sub_storage
:
{
type
:
"
dummystorage1
"
}
});
DummyStorage
.
prototype
.
removeAttachment
=
function
(
id
,
name
)
{
equal
(
id
,
"
1
"
);
equal
(
name
,
"
test_name
"
);
return
"
removed
"
;
};
jio
.
removeAttachment
(
"
1
"
,
"
test_name
"
)
.
then
(
function
(
result
)
{
equal
(
result
,
"
removed
"
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
/////////////////////////////////////////////////////////////////
// ListStorage.hasCapacity
/////////////////////////////////////////////////////////////////
module
(
"
ListStorage.hasCapacity
"
);
test
(
"
list capacity is implemented
"
,
function
()
{
var
jio
=
jIO
.
createJIO
({
type
:
"
list
"
,
sub_storage
:
{
type
:
"
dummystorage1
"
}
});
DummyStorage
.
prototype
.
hasCapacity
=
function
()
{
return
false
;
};
ok
(
jio
.
hasCapacity
(
"
list
"
));
});
}(
jIO
,
QUnit
));
\ No newline at end of file
test/node.js
View file @
2233e321
...
@@ -64,6 +64,7 @@
...
@@ -64,6 +64,7 @@
'
test/jio.storage/erp5storage.tests.js
'
,
'
test/jio.storage/erp5storage.tests.js
'
,
'
test/jio.storage/fbstorage.tests.js
'
,
'
test/jio.storage/fbstorage.tests.js
'
,
'
test/jio.storage/gdrivestorage.tests.js
'
,
'
test/jio.storage/gdrivestorage.tests.js
'
,
'
test/jio.storage/liststorage.tests.js
'
,
'
test/jio.storage/memorystorage.tests.js
'
,
'
test/jio.storage/memorystorage.tests.js
'
,
'
test/jio.storage/nocapacitystorage.tests.js
'
,
'
test/jio.storage/nocapacitystorage.tests.js
'
,
'
test/jio.storage/querystorage.tests.js
'
,
'
test/jio.storage/querystorage.tests.js
'
,
...
...
test/tests.html
View file @
2233e321
...
@@ -78,6 +78,7 @@ See https://www.nexedi.com/licensing for rationale and options.
...
@@ -78,6 +78,7 @@ See https://www.nexedi.com/licensing for rationale and options.
<script
src=
"jio.storage/fbstorage.tests.js"
></script>
<script
src=
"jio.storage/fbstorage.tests.js"
></script>
<script
src=
"jio.storage/httpstorage.tests.js"
></script>
<script
src=
"jio.storage/httpstorage.tests.js"
></script>
<script
src=
"jio.storage/nocapacitystorage.tests.js"
></script>
<script
src=
"jio.storage/nocapacitystorage.tests.js"
></script>
<script
src=
"jio.storage/liststorage.tests.js"
></script>
<!--script src="../src/jio.storage/xwikistorage.js"></script>
<!--script src="../src/jio.storage/xwikistorage.js"></script>
<script src="jio.storage/xwikistorage.tests.js"></script-->
<script src="jio.storage/xwikistorage.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