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
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
Commits
0c109099
Commit
0c109099
authored
Dec 28, 2012
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jiotests tools updated + docstring
parent
5d75e14f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
11 deletions
+38
-11
test/jiotests.js
test/jiotests.js
+38
-11
No files found.
test/jiotests.js
View file @
0c109099
...
@@ -70,16 +70,42 @@ basicTestFunctionGenerator = function(o,res,value,message) {
...
@@ -70,16 +70,42 @@ basicTestFunctionGenerator = function(o,res,value,message) {
deepEqual
(
val
,
value
,
message
);
deepEqual
(
val
,
value
,
message
);
};
};
},
},
basicSpyFunction
=
function
(
o
,
res
,
value
,
message
,
fun
)
{
fun
=
fun
||
'
f
'
;
/**
o
[
fun
]
=
basicTestFunctionGenerator
(
o
,
res
,
value
,
message
);
* Prepare a specific test for jio and create a spy.
o
.
t
.
spy
(
o
,
fun
);
* It creates a function [function_name] in [obj] which can be use as a
* jio callback. To prepare the test, we need to know what kind of return
* value you want -> [result_type]:
* - "status": [value] is compared with err.status, the error code
* - "jobstatus": [value] check if the request is "fail" or "done"
* - "value": [value] is compared to the response
* @method basicSpyFunction
* @param {object} obj The object to work with
* @param {string} result_type The result type
* @param {object} value The value to be compared
* @param {string} message The test message
* @param {string} function_name The callback name
*/
basicSpyFunction
=
function
(
obj
,
result_type
,
value
,
message
,
function_name
)
{
function_name
=
function_name
||
'
f
'
;
obj
[
function_name
]
=
basicTestFunctionGenerator
(
obj
,
result_type
,
value
,
message
);
obj
.
t
.
spy
(
obj
,
function_name
);
},
},
basicTickFunction
=
function
(
o
)
{
/**
* Advances in time and execute the test previously prepared.
* The default function to test is "f" in [obj].
* @method basicTickFunction
* @param {object} obj The object to work with
* @param {number} tick The time to advance in ms (optional)
* @param {function_name} function_name The callback to test (optional)
*/
basicTickFunction
=
function
(
obj
)
{
var
tick
,
fun
,
i
=
1
;
var
tick
,
fun
,
i
=
1
;
tick
=
10000
;
tick
=
10000
;
fun
=
fun
||
'
f
'
;
fun
=
"
f
"
;
if
(
typeof
arguments
[
i
]
===
'
number
'
)
{
if
(
typeof
arguments
[
i
]
===
'
number
'
)
{
tick
=
arguments
[
i
];
i
++
;
tick
=
arguments
[
i
];
i
++
;
...
@@ -87,12 +113,12 @@ basicTickFunction = function (o) {
...
@@ -87,12 +113,12 @@ basicTickFunction = function (o) {
if
(
typeof
arguments
[
i
]
===
'
string
'
)
{
if
(
typeof
arguments
[
i
]
===
'
string
'
)
{
fun
=
arguments
[
i
];
i
++
;
fun
=
arguments
[
i
];
i
++
;
}
}
o
.
clock
.
tick
(
tick
);
o
bj
.
clock
.
tick
(
tick
);
if
(
!
o
[
fun
].
calledOnce
)
{
if
(
!
o
bj
[
fun
].
calledOnce
)
{
if
(
o
[
fun
].
called
)
{
if
(
o
bj
[
fun
].
called
)
{
ok
(
false
,
'
too much results (o.
'
+
fun
+
'
)
'
);
ok
(
false
,
'
too much results (o
bj
.
'
+
fun
+
'
)
'
);
}
else
{
}
else
{
ok
(
false
,
'
no response (o.
'
+
fun
+
'
)
'
);
ok
(
false
,
'
no response (o
bj
.
'
+
fun
+
'
)
'
);
}
}
}
}
},
},
...
@@ -755,6 +781,7 @@ test ("Put", function(){
...
@@ -755,6 +781,7 @@ test ("Put", function(){
});
});
// put without id
// put without id
// error 20 -> document id required
o
.
spy
(
o
,
"
status
"
,
20
,
"
Put without id
"
);
o
.
spy
(
o
,
"
status
"
,
20
,
"
Put without id
"
);
o
.
jio
.
put
({},
o
.
f
);
o
.
jio
.
put
({},
o
.
f
);
o
.
tick
(
o
);
o
.
tick
(
o
);
...
...
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