164 lines
5.6 KiB
HTML
164 lines
5.6 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>taoApi Test Suite</title>
|
|
<link rel="stylesheet" href="../../tao/test/qunit/qunit.css" type="text/css" media="screen">
|
|
<script type="text/javascript" src='../../tao/views/js/jquery-1.8.0.min.js'></script>
|
|
<script type="text/javascript" src="../../tao/test/qunit/qunit.js"></script>
|
|
<script type="text/javascript" src="../views/js/taoApi/taoApi.min.js"></script>
|
|
<script type="text/javascript" src="../../wfEngine/views/js/wfApi/wfApi.min.js"></script>
|
|
<script type="text/javascript">
|
|
|
|
module("constants");
|
|
|
|
test("Test the constants availability", function() {
|
|
ok( (URI != null), 'the URI constant should not be null');
|
|
ok( (URI.LABEL != undefined), 'the URI has a LABEL property');
|
|
equals( STATE.ITEM.FINISHED, 'item_finished', 'the state finished is defined ');
|
|
});
|
|
|
|
module("core");
|
|
|
|
test("Test an instance of the TaoStack class", function() {
|
|
ok(isScalar(12), 'test the isScalar function with an integer');
|
|
ok(isScalar(1.2), 'test the isScalar function with a float');
|
|
ok(isScalar(true), 'test the isScalar function with a boolean');
|
|
ok(isScalar("douze"), 'test the isScalar function with a string');
|
|
ok(!isScalar([1,2]), 'test the isScalar function with an array ');
|
|
ok(!isScalar({douze:12}), 'test the isScalar function with an object');
|
|
|
|
var aTaoStack = new TaoStack();
|
|
ok( (aTaoStack != null), 'the taoStack instance should not be null');
|
|
ok( !$.isPlainObject(aTaoStack), 'check if the taoStack is not a plain object');
|
|
ok( (aTaoStack instanceof TaoStack), 'check the taoStack Class');
|
|
ok( (typeof(aTaoStack) === 'object'), 'check the taoStack type');
|
|
});
|
|
|
|
test("Test the global TaoStack instance used by the API", function() {
|
|
|
|
ok( (taoStack != undefined), 'the taoStack instance should defined');
|
|
ok( !$.isPlainObject(taoStack), 'check if the taoStack is not a plain object');
|
|
ok( (taoStack instanceof TaoStack), 'check the taoStack Class');
|
|
ok( (typeof(taoStack) === 'object'), 'check the taoStack type');
|
|
});
|
|
|
|
module("dataSource");
|
|
|
|
test("Test the API with a Manual Data Source", function() {
|
|
var taoEnv = new Object();
|
|
taoEnv['token'] = "7114e56cb3b9423314a425500afb41fc56183000"; //the token must comes from the server: taoEnv['token'] = "<?php echo $token; ?>";
|
|
taoEnv['localNamespace'] = "http://tao.localdomain/middleware/mytao.rdf";
|
|
taoEnv[URI.PROCESS] = {'uri': "http://tao.localdomain/middleware/mytao.rdf#i1123467865"};
|
|
taoEnv[URI.PROCESS][URI.LABEL] = "Bachelor MATH 2010 SES012";
|
|
taoEnv[URI.DELIVERY] = {'uri': "http://tao.localdomain/middleware/mytao.rdf#i1123467865"};
|
|
taoEnv[URI.DELIVERY][URI.LABEL] = "Bachelor MATH 2010";
|
|
taoEnv[URI.TEST] = {'uri': "http://tao.localdomain/middleware/mytao.rdf#i1123876239763"};
|
|
taoEnv[URI.TEST][URI.LABEL] = "ALGEBER 2010";
|
|
taoEnv[URI.ITEM] = {'uri': "http://tao.localdomain/middleware/mytao.rdf#i1123468712345"};
|
|
taoEnv[URI.ITEM][URI.LABEL] = "Matrix level 2";
|
|
taoEnv[URI.SUBJECT] = {'uri': "http://tao.localdomain/middleware/mytao.rdf#i1284379754048297800"};
|
|
taoEnv[URI.SUBJECT][URI.LABEL] = "User_jdoe";
|
|
taoEnv[URI.SUBJECT][URI.SUBJETC_LOGIN] = "jdoe17";
|
|
taoEnv[URI.SUBJECT][URI.SUBJETC_FIRSTNAME] = "John";
|
|
taoEnv[URI.SUBJECT][URI.SUBJETC_LASTNAME] = "Doe";
|
|
|
|
ok( $.isPlainObject(taoEnv), 'check if the taoEnv is a plain object');
|
|
|
|
initManualDataSource(taoEnv);
|
|
initPush({
|
|
url : 'taoApiServer.php?action=push',
|
|
params: {
|
|
token : getToken()
|
|
}
|
|
});
|
|
|
|
equals(getSubjectLogin(), "jdoe17", 'Test if the login is set');
|
|
|
|
equals(getToken(), "7114e56cb3b9423314a425500afb41fc56183000", 'Test if the token matches');
|
|
|
|
setUserVar('tempScore', 14);
|
|
|
|
equals(getUserVar('tempScore'), 14, 'Test the user variables');
|
|
|
|
setEndorsment(true);
|
|
|
|
push();
|
|
|
|
equals(getUserVar('tempScore'), false, 'Test if the stack is cleared');
|
|
|
|
setUserVar('tempScore2', 12);
|
|
|
|
equals(getUserVar('tempScore2'), 12, 'Test the user variables');
|
|
|
|
|
|
|
|
});
|
|
|
|
module("events");
|
|
|
|
test("Test the global EventTracer instance used by the API", function() {
|
|
|
|
ok( (eventTracer != undefined), 'the eventTracer instance should defined');
|
|
ok( !$.isPlainObject(eventTracer), 'check if the eventTracer is not a plain object');
|
|
ok( (eventTracer instanceof EventTracer), 'check the eventTracer Class');
|
|
ok( (typeof(eventTracer) === 'object'), 'check the eventTracer type');
|
|
});
|
|
|
|
test("Test the events API with a Manual Source", function() {
|
|
|
|
var clientEvents = {"type":"catch","list":{"click":[],"keyup":[],"keypress":[]}};
|
|
|
|
initEventServices({
|
|
type: 'manual',
|
|
data: clientEvents
|
|
},{
|
|
url : 'taoApiServer.php?action=traceEvents',
|
|
params: {
|
|
token : getToken()
|
|
}
|
|
});
|
|
|
|
logEvent('div', 'click', {id: "qunit-fixture"});
|
|
|
|
ok(eventTracer.eventPool.length > 0, 'Test if the event has been correctly logged');
|
|
|
|
logCustomEvent('TEST', {id:12});
|
|
|
|
|
|
});
|
|
|
|
module("state");
|
|
|
|
test("Finishing", function(){
|
|
|
|
logEvent('h1', 'click', {id: "qunit-header"});
|
|
logEvent('h2', 'click', {id: "qunit-banner"});
|
|
|
|
var testCallBack = 2;
|
|
onFinish(function(){
|
|
testCallBack++;
|
|
});
|
|
|
|
equals(testCallBack, 2, 'Test the finish callback');
|
|
|
|
finish();
|
|
|
|
equals(testCallBack, 3, 'Test the finish callback');
|
|
|
|
equals(getUserVar('tempScore2'), false, 'Test if the stack is cleared');
|
|
|
|
ok(eventTracer.eventPool.length == 0, "Test if the events has been sent");
|
|
});
|
|
</script>
|
|
|
|
</head>
|
|
<body>
|
|
<h1 id="qunit-header">TAO API Test Suite</h1>
|
|
<h2 id="qunit-banner"></h2>
|
|
<div id="qunit-testrunner-toolbar"></div>
|
|
<h2 id="qunit-userAgent"></h2>
|
|
<ol id="qunit-tests"></ol>
|
|
<div id="qunit-fixture">test markup</div>
|
|
</body>
|
|
</html>
|