Fix #1190 Use phantom JS to run qunit tests

This commit is contained in:
Nicolas Le Goff
2013-05-30 19:42:44 +02:00
parent a5cc876959
commit acb66d6f92
5 changed files with 48 additions and 45 deletions

View File

@@ -63,6 +63,9 @@ matrix:
- php: 5.5 - php: 5.5
script: script:
- phantomjs www/assets/qunit/addons/phantomjs/runner.js www/include/js/tests/jquery.Upload.js.html
- phantomjs www/assets/qunit/addons/phantomjs/runner.js www/include/js/tests/jquery.Edit.js.html
- phantomjs www/assets/qunit/addons/phantomjs/runner.js www/include/js/tests/jquery.Selection.js.html
- sh tests/js/scripts/run.sh --single-run - sh tests/js/scripts/run.sh --single-run
- mocha-phantomjs www/scripts/tests/index.html - mocha-phantomjs www/scripts/tests/index.html
- phpunit - phpunit

View File

@@ -15,7 +15,7 @@
"json3" : "3.2.4", "json3" : "3.2.4",
"bootstrap-switch": "https://github.com/nostalgiaz/bootstrap-switch.git", "bootstrap-switch": "https://github.com/nostalgiaz/bootstrap-switch.git",
"humane-js": "~3.0.6", "humane-js": "~3.0.6",
"qunit": "~1.11.0", "qunit": "https://github.com/jquery/qunit.git#1.11.0",
"mustache": "~0.7.2", "mustache": "~0.7.2",
"jquery-file-upload": "https://github.com/blueimp/jQuery-File-Upload/archive/75d11179fd9c248c061c8eb428782bb556c8db0a.zip", "jquery-file-upload": "https://github.com/blueimp/jQuery-File-Upload/archive/75d11179fd9c248c061c8eb428782bb556c8db0a.zip",
"blueimp-load-image": "latest", "blueimp-load-image": "latest",

View File

@@ -3,10 +3,10 @@
<head> <head>
<title></title> <title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="http://code.jquery.com/jquery-latest.js"></script> <script src="../../../assets/jquery/jquery.js"></script>
<script src="/include/vendor/qunit/qunit/qunit.js"></script> <script src="../../../assets/qunit/qunit/qunit.js"></script>
<script src="../jquery.Edit.js"></script> <script src="../jquery.Edit.js"></script>
<link type="text/css" rel="stylesheet" href="/assets/qunit/qunit.css"/> <link type="text/css" rel="stylesheet" href="../../../assets/qunit/qunit/qunit.css"/>
<script> $(document).ready(function(){ <script> $(document).ready(function(){

View File

@@ -3,13 +3,13 @@
<head> <head>
<title></title> <title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="http://code.jquery.com/jquery-latest.js"></script> <script src="../../../assets/jquery/jquery.js"></script>
<script src="/include/vendor/qunit/qunit/qunit.js"></script> <script src="../../../assets/qunit/qunit/qunit.js"></script>
<script src="../jquery.Selection.js"></script> <script src="../jquery.Selection.js"></script>
<link type="text/css" rel="stylesheet" href="/assets/qunit/qunit.css"/> <link type="text/css" rel="stylesheet" href="../../../assets/qunit/qunit.css"/>
<script> $(document).ready(function(){ <script> $(document).ready(function(){
test("Selection instanciation", function() { test("Selection instanciation", function() {
var sel = new Selectable($('#test_box2')); var sel = new Selectable($('#test_box2'));
var array = new Array(); var array = new Array();
@@ -18,26 +18,26 @@
}); });
module("Add datas"); module("Add datas");
test("first test within module", function() { test("first test within module", function() {
var sel = new Selectable($('#test_box3')); var sel = new Selectable($('#test_box3'));
sel.push('a'); sel.push('a');
equal( 1, sel.get().length, "We expect the selection to be empty" ); equal( 1, sel.get().length, "We expect the selection to be empty" );
equal( 'a', sel.get().pop(), "We expect the selection to be empty" ); equal( 'a', sel.get().pop(), "We expect the selection to be empty" );
}); });
module("Multiple selections"); module("Multiple selections");
test("first test within module", function() { test("first test within module", function() {
var sel1 = new Selectable($('#test_box4')); var sel1 = new Selectable($('#test_box4'));
var sel2 = new Selectable($('#test_box5')); var sel2 = new Selectable($('#test_box5'));
sel1.push('a'); sel1.push('a');
sel2.push('b'); sel2.push('b');
equal( 1, sel1.get().length, "We expect the selection to be empty" ); equal( 1, sel1.get().length, "We expect the selection to be empty" );
equal( 'a', sel1.get().pop(), "We expect the selection to be empty" ); equal( 'a', sel1.get().pop(), "We expect the selection to be empty" );
equal( 1, sel2.get().length, "We expect the selection to be empty" ); equal( 1, sel2.get().length, "We expect the selection to be empty" );
equal( 'b', sel2.get().pop(), "We expect the selection to be empty" ); equal( 'b', sel2.get().pop(), "We expect the selection to be empty" );
}); });
@@ -52,16 +52,16 @@
, callbackSelection : function(elem){ , callbackSelection : function(elem){
var lst = jQuery('li', $('#test_box1')); var lst = jQuery('li', $('#test_box1'));
var index = jQuery.inArray( elem[0], lst ); var index = jQuery.inArray( elem[0], lst );
return 'item' + index; return 'item' + index;
} }
} }
); );
equal(true, $('#test_box1').hasClass('selectionnable')); equal(true, $('#test_box1').hasClass('selectionnable'));
equal(0, sel1.length(), 'Nothing is selected'); equal(0, sel1.length(), 'Nothing is selected');
equal(0, sel1.size(), 'Nothing is selected'); equal(0, sel1.size(), 'Nothing is selected');
sel1.selectAll(); sel1.selectAll();
equal(0, $('#test_box li:not(.selected)').length); equal(0, $('#test_box li:not(.selected)').length);
@@ -76,57 +76,57 @@
$('#test_box1 li:not(.selected):first').trigger('click'); $('#test_box1 li:not(.selected):first').trigger('click');
equal(1, sel1.size(), 'First element selection'); equal(1, sel1.size(), 'First element selection');
var SKevent = jQuery.Event('click', { shiftKey : true }); var SKevent = jQuery.Event('click', { shiftKey : true });
$('#test_box1 li:not(.selected)').filter(':last').trigger(SKevent); $('#test_box1 li:not(.selected)').filter(':last').trigger(SKevent);
equal(sel1.length(), 10, 'Shift click selection'); equal(sel1.length(), 10, 'Shift click selection');
equal(sel1.size(), 10); equal(sel1.size(), 10);
sel1.empty(); sel1.empty();
equal(0, $('#test_box li:not(.selected)').length); equal(0, $('#test_box li:not(.selected)').length);
$('#test_box1 li:not(.selected):last').trigger('click'); $('#test_box1 li:not(.selected):last').trigger('click');
equal(1, sel1.size(), 'Last element selection'); equal(1, sel1.size(), 'Last element selection');
var SKevent = jQuery.Event('click', { shiftKey : true }); var SKevent = jQuery.Event('click', { shiftKey : true });
$('#test_box1 li:not(.selected)').filter(':first').trigger(SKevent); $('#test_box1 li:not(.selected)').filter(':first').trigger(SKevent);
equal(sel1.length(), 10, 'Shift click selection reversed'); equal(sel1.length(), 10, 'Shift click selection reversed');
equal(sel1.size(), 10); equal(sel1.size(), 10);
$('#test_box1 li:first').trigger('click'); $('#test_box1 li:first').trigger('click');
equal(sel1.length(), 1, 'Start new selection'); equal(sel1.length(), 1, 'Start new selection');
equal($('#test_box1 li:last').hasClass('selected'), false, 'last item does not have selected class'); equal($('#test_box1 li:last').hasClass('selected'), false, 'last item does not have selected class');
var CKevent = jQuery.Event('click', { ctrlKey : true }); var CKevent = jQuery.Event('click', { ctrlKey : true });
$('#test_box1 li:last').trigger(CKevent); $('#test_box1 li:last').trigger(CKevent);
equal(sel1.length(), 2, 'Ctrl click'); equal(sel1.length(), 2, 'Ctrl click');
var CKevent = jQuery.Event('click', { ctrlKey : true }); var CKevent = jQuery.Event('click', { ctrlKey : true });
$('#test_box1 li:last').trigger(CKevent); $('#test_box1 li:last').trigger(CKevent);
equal(sel1.length(), 1, 'Ctrl click'); equal(sel1.length(), 1, 'Ctrl click');
var CKevent = jQuery.Event('click', { ctrlKey : true }); var CKevent = jQuery.Event('click', { ctrlKey : true });
$('#test_box1 li:last').trigger(CKevent); $('#test_box1 li:last').trigger(CKevent);
equal(sel1.length(), 2, 'Ctrl click'); equal(sel1.length(), 2, 'Ctrl click');
equal(sel1.serialize(), 'item0;item9'); equal(sel1.serialize(), 'item0;item9');
equal(sel1.serialize('!u'), 'item0!uitem9'); equal(sel1.serialize('!u'), 'item0!uitem9');
}); });
}); });
</script> </script>
</head> </head>

View File

@@ -3,12 +3,12 @@
<head> <head>
<title></title> <title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="http://code.jquery.com/jquery-latest.js"></script> <script src="../../../assets/jquery/jquery.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.js"></script> <script src="../../jslibs/jquery-ui-1.8/js/jquery-ui-1.8.17.custom.min.js"></script>
<script src="/include/vendor/qunit/qunit/qunit.js"></script> <script src="../../../assets/qunit/qunit/qunit.js"></script>
<script src="/include/jslibs/blueimp.load-image.js"></script> <script src="../../../assets/blueimp-load-image/load-image.js"></script>
<script src="../../../skins/prod/jquery.Upload.js"></script> <script src="../../../skins/prod/jquery.Upload.js"></script>
<link type="text/css" rel="stylesheet" href="/assets/qunit/qunit.css"/> <link type="text/css" rel="stylesheet" href="../../../assets/qunit/qunit/qunit.css"/>
<script> $(document).ready(function(){ <script> $(document).ready(function(){
var getUploadManager = function(){ var getUploadManager = function(){