fix tests order

This commit is contained in:
vitalets 2012-12-10 15:13:19 +04:00
parent 819bcfcd30
commit 00450916e2
7 changed files with 44 additions and 26 deletions

@ -145,7 +145,8 @@ define(function () {
return { return {
baseUrl: baseUrl, baseUrl: baseUrl,
paths: { paths: {
"bootstrap": "../test/libs/bootstrap221", // "bootstrap": "../test/libs/bootstrap221",
"bootstrap": "../test/libs/bootstrap222",
"jqueryui": "../test/libs/jquery-ui-1.9.1.custom", "jqueryui": "../test/libs/jquery-ui-1.9.1.custom",
"poshytip": "../test/libs/poshytip", "poshytip": "../test/libs/poshytip",
"test": "../test" "test": "../test"

@ -4,30 +4,41 @@ var jqver = decodeURIComponent((new RegExp('[?|&]' + 'jquery' + '=' + '([^&;]+?)
require(["loader", jqurl], function(loader) { require(["loader", jqurl], function(loader) {
requirejs.config(loader.getConfig("../src")); var config = loader.getConfig("../src"),
params = loader.getParams();
//add test specific dependencies
config.shim['test/mocks'] = ['element/editable-element', 'test/libs/mockjax/jquery.mockjax'];
//as we need to keep order of tests, create shim dependencies automatically
addTests(config);
requirejs.config(config);
require(['element/editable-element', require(['test/unit/api'],
'test/libs/mockjax/jquery.mockjax'
],
function() { function() {
//disable effects //disable effects
$.fx.off = true; $.fx.off = true;
$.support.transition = false; $.support.transition = false;
var params = loader.getParams(); QUnit.load();
QUnit.start();
require([ });
function addTests(config) {
var tests = [
'test/mocks', 'test/mocks',
'test/unit/common', 'test/unit/common',
'test/unit/text', 'test/unit/text',
'test/unit/textarea', 'test/unit/textarea',
'test/unit/select', 'test/unit/select',
'test/unit/checklist', 'test/unit/checklist',
'test/unit/api', (params.f === 'bootstrap') ? 'test/unit/date' : 'test/unit/dateui',
(params.f === 'bootstrap') ? 'test/unit/date' : 'test/unit/dateui' 'test/unit/api'
], function() { ];
QUnit.load();
QUnit.start(); for(var i=0; i<tests.length-1; i++) {
}); config.shim[tests[i+1]] = [tests[i]];
}); }
}
}); });

@ -57,7 +57,7 @@ $(function () {
}); });
// useful functions // usefull functions
function tip(e) { function tip(e) {
return e.data('editableContainer').tip(); return e.data('editableContainer').tip();

@ -223,12 +223,12 @@ $(function () {
var ev1 = 'ev1', var ev1 = 'ev1',
ev2 = 'ev2', ev2 = 'ev2',
e1v = 'e1v', e1v = 'e1v',
e = $('<a href="#" class="new" data-type="text" data-url="post.php" data-name="text">'+ev1+'</a>').appendTo(fx).editable({ e = $('<a href="#" class="new-val" data-type="text" data-url="post.php" data-name="text">'+ev1+'</a>').appendTo(fx).editable({
validate: function(value) { validate: function(value) {
if(value == ev1) return 'invalid'; if(value == ev1) return 'invalid';
} }
}), }),
e1 = $('<a href="#" class="new" data-type="text" data-name="text1">'+e1v+'</a>').appendTo(fx).editable(); e1 = $('<a href="#" class="new-val" data-type="text" data-name="text1">'+e1v+'</a>').appendTo(fx).editable();
$.mockjax({ $.mockjax({
url: 'new-error.php', url: 'new-error.php',
@ -251,7 +251,7 @@ $(function () {
} }
}); });
$(fx).find('.new').editable('submit', { $(fx).find('.new-val').editable('submit', {
url: 'new.php', url: 'new.php',
error: function(errors) { error: function(errors) {
equal(errors.text, 'invalid', 'client validation error ok'); equal(errors.text, 'invalid', 'client validation error ok');
@ -264,7 +264,7 @@ $(function () {
p.find('input[type=text]').val(ev2); p.find('input[type=text]').val(ev2);
p.find('button[type=submit]').click(); p.find('button[type=submit]').click();
$(fx).find('.new').editable('submit', { $(fx).find('.new-val').editable('submit', {
url: 'new-error.php', url: 'new-error.php',
data: {a: 123}, data: {a: 123},
success: function(data, config) { success: function(data, config) {
@ -301,14 +301,14 @@ $(function () {
asyncTest("'submit' method: server error", function () { asyncTest("'submit' method: server error", function () {
var ev1 = 'ev1', var ev1 = 'ev1',
e1v = 'e1v', e1v = 'e1v',
e = $('<a href="#" class="new" data-type="text" data-url="post.php" data-name="text">'+ev1+'</a>').appendTo(fx).editable(), e = $('<a href="#" class="new-err" data-type="text" data-url="post.php" data-name="text">'+ev1+'</a>').appendTo(fx).editable(),
e1 = $('<a href="#" class="new" data-type="text" data-name="text1">'+e1v+'</a>').appendTo(fx).editable(); e1 = $('<a href="#" class="new-err" data-type="text" data-name="text1">'+e1v+'</a>').appendTo(fx).editable();
$(fx).find('.new').editable('submit', { $(fx).find('.new-err').editable('submit', {
url: 'error.php', url: 'error.php',
error: function(data) { error: function(data) {
equal(this[0], $(fx).find('.new')[0], 'success context ok'); equal(this[0], $(fx).find('.new-err')[0], 'success context ok');
equal(this[1], $(fx).find('.new')[1], 'success context2 ok'); equal(this[1], $(fx).find('.new-err')[1], 'success context2 ok');
equal(data.status, 500, 'status 500 ok'); equal(data.status, 500, 'status 500 ok');
equal(data.responseText, 'customtext', 'server error ok'); equal(data.responseText, 'customtext', 'server error ok');
@ -347,6 +347,9 @@ $(function () {
e.remove(); e.remove();
e1.remove(); e1.remove();
start(); start();
},
error: function(errors) {
ok(false, 'error should not be called');
} }
}); });

@ -3,7 +3,8 @@ $(function () {
module("checklist", { module("checklist", {
setup: function(){ setup: function(){
sfx = $('#qunit-fixture'), sfx = $('#qunit-fixture'),
fx = $('#async-fixture'); fx = $('#async-fixture');
$.support.transition = false;
} }
}); });

@ -6,6 +6,7 @@ $(function () {
setup: function(){ setup: function(){
fx = $('#async-fixture'); fx = $('#async-fixture');
dpg = $.fn.datepicker.DPGlobal; dpg = $.fn.datepicker.DPGlobal;
$.support.transition = false;
} }
}); });

@ -5,6 +5,7 @@ $(function () {
module("dateui", { module("dateui", {
setup: function(){ setup: function(){
fx = $('#async-fixture'); fx = $('#async-fixture');
$.support.transition = false;
} }
}); });