Commit 0b8d4e96 authored by Tristan Cavelier's avatar Tristan Cavelier

jiotests tools updated

parent f19a4f95
...@@ -123,30 +123,44 @@ generateTools = function (sinon) { ...@@ -123,30 +123,44 @@ generateTools = function (sinon) {
o.clock.tick(base_tick); o.clock.tick(base_tick);
o.spy = basicSpyFunction; o.spy = basicSpyFunction;
o.tick = basicTickFunction; o.tick = basicTickFunction;
// test methods
o.testLastJobLabel = function (label, mess) { o.testLastJobLabel = function (label, mess) {
deepEqual( var lastjob = getLastJob(o.jio.getId());
getLastJob(o.jio.getId()).command.label, if (lastjob) {
label, deepEqual(lastjob.command.label, label, mess);
mess } else {
); deepEqual("No job on the queue", "Job with label: "+label, mess);
}
}; };
o.testLastJobId = function (id, mess) { o.testLastJobId = function (id, mess) {
deepEqual( var lastjob = getLastJob(o.jio.getId());
getLastJob(o.jio.getId()).id, if (lastjob) {
id, deepEqual(lastjob.id, id, mess);
mess } else {
); deepEqual("No job on the queue", "Job with id: "+id, mess);
}
}; };
o.testLastJobWaitForTime = function (mess) { o.testLastJobWaitForTime = function (mess) {
ok(getLastJob(o.jio.getId()).status.waitfortime > 0, mess); var lastjob = getLastJob(o.jio.getId());
if (lastjob) {
ok(lastjob.status.waitfortime > 0, mess);
} else {
deepEqual("No job on the queue", "Job waiting for time", mess);
}
}; };
o.testLastJobWaitForJob = function (job_id_array, mess) { o.testLastJobWaitForJob = function (job_id_array, mess) {
deepEqual( var lastjob = getLastJob(o.jio.getId());
getLastJob(o.jio.getId()).status.waitforjob, if (lastjob) {
job_id_array, deepEqual(lastjob.status.waitforjob, job_id_array, mess);
mess } else {
); deepEqual(
"No job on the queue",
"Job waiting for: " + JSON.stringify (job_id_array),
mess
);
}
}; };
// wait method
o.waitUntilAJobExists = function (timeout) { o.waitUntilAJobExists = function (timeout) {
var cpt = 0 var cpt = 0
while (true) { while (true) {
...@@ -154,7 +168,7 @@ generateTools = function (sinon) { ...@@ -154,7 +168,7 @@ generateTools = function (sinon) {
break; break;
} }
if (timeout >= cpt) { if (timeout >= cpt) {
ok(false, "no job added to the queue"); ok(false, "No job were added to the queue");
break; break;
} }
o.clock.tick(25); o.clock.tick(25);
...@@ -164,7 +178,7 @@ generateTools = function (sinon) { ...@@ -164,7 +178,7 @@ generateTools = function (sinon) {
o.waitUntilLastJobIs = function (state) { o.waitUntilLastJobIs = function (state) {
while (true) { while (true) {
if (getLastJob(o.jio.getId()) === undefined) { if (getLastJob(o.jio.getId()) === undefined) {
ok(false, "a job is never called"); ok(false, "No job have state: " + state);
break; break;
} }
if (getLastJob(o.jio.getId()).status.label === state) { if (getLastJob(o.jio.getId()).status.label === state) {
...@@ -174,10 +188,18 @@ generateTools = function (sinon) { ...@@ -174,10 +188,18 @@ generateTools = function (sinon) {
} }
}; };
return o; return o;
}; },
//// end tools //// end tools
//// test methods //// //// test function
isUuid = function (uuid) {
var x = "[0-9a-fA-F]{4}";
if (typeof uuid !== "string" ) {
return false;
}
return uuid.match("^"+x+x+"-"+x+"-"+x+"-"+x+"-"+x+x+x+"$") === null?
false: true;
};
//// QUnit Tests //// //// QUnit Tests ////
module ('Jio Global tests'); module ('Jio Global tests');
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
<script type="text/javascript" src="../lib/jsSha2/sha2.js"></script> <script type="text/javascript" src="../lib/jsSha2/sha2.js"></script>
<script type="text/javascript" src="../src/jio.dummystorages.js"></script> <script type="text/javascript" src="../src/jio.dummystorages.js"></script>
<script type="text/javascript" src="../jio.storage.js"></script> <script type="text/javascript" src="../jio.storage.js"></script>
<script type="text/javascript" src="../src/jio.storage/revisionstorage.js">
</script>
<script type="text/javascript" src="./jiotests.js"></script> <script type="text/javascript" src="./jiotests.js"></script>
</body> </body>
</html> </html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment