diff --git a/test/loader.js b/test/loader.js index 3ccb962..d961fa4 100644 --- a/test/loader.js +++ b/test/loader.js @@ -145,7 +145,8 @@ define(function () { return { baseUrl: baseUrl, paths: { - "bootstrap": "../test/libs/bootstrap221", +// "bootstrap": "../test/libs/bootstrap221", + "bootstrap": "../test/libs/bootstrap222", "jqueryui": "../test/libs/jquery-ui-1.9.1.custom", "poshytip": "../test/libs/poshytip", "test": "../test" diff --git a/test/main.js b/test/main.js index 6264575..d15b23b 100644 --- a/test/main.js +++ b/test/main.js @@ -4,30 +4,41 @@ var jqver = decodeURIComponent((new RegExp('[?|&]' + 'jquery' + '=' + '([^&;]+?) 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', - 'test/libs/mockjax/jquery.mockjax' - ], + require(['test/unit/api'], function() { //disable effects $.fx.off = true; $.support.transition = false; - var params = loader.getParams(); - - require([ + QUnit.load(); + QUnit.start(); + }); + + function addTests(config) { + var tests = [ 'test/mocks', 'test/unit/common', 'test/unit/text', 'test/unit/textarea', 'test/unit/select', 'test/unit/checklist', - 'test/unit/api', - (params.f === 'bootstrap') ? 'test/unit/date' : 'test/unit/dateui' - ], function() { - QUnit.load(); - QUnit.start(); - }); - }); + (params.f === 'bootstrap') ? 'test/unit/date' : 'test/unit/dateui', + 'test/unit/api' + ]; + + for(var i=0; i<tests.length-1; i++) { + config.shim[tests[i+1]] = [tests[i]]; + } + } }); \ No newline at end of file diff --git a/test/mocks.js b/test/mocks.js index 446c901..46d7a4f 100644 --- a/test/mocks.js +++ b/test/mocks.js @@ -57,7 +57,7 @@ $(function () { }); -// useful functions +// usefull functions function tip(e) { return e.data('editableContainer').tip(); diff --git a/test/unit/api.js b/test/unit/api.js index e58595c..f432e18 100644 --- a/test/unit/api.js +++ b/test/unit/api.js @@ -223,12 +223,12 @@ $(function () { var ev1 = 'ev1', ev2 = 'ev2', 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) { 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({ url: 'new-error.php', @@ -251,7 +251,7 @@ $(function () { } }); - $(fx).find('.new').editable('submit', { + $(fx).find('.new-val').editable('submit', { url: 'new.php', error: function(errors) { equal(errors.text, 'invalid', 'client validation error ok'); @@ -264,7 +264,7 @@ $(function () { p.find('input[type=text]').val(ev2); p.find('button[type=submit]').click(); - $(fx).find('.new').editable('submit', { + $(fx).find('.new-val').editable('submit', { url: 'new-error.php', data: {a: 123}, success: function(data, config) { @@ -301,14 +301,14 @@ $(function () { asyncTest("'submit' method: server error", function () { var ev1 = 'ev1', e1v = 'e1v', - e = $('<a href="#" class="new" 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(); + 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-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', error: function(data) { - equal(this[0], $(fx).find('.new')[0], 'success context ok'); - equal(this[1], $(fx).find('.new')[1], 'success context2 ok'); + equal(this[0], $(fx).find('.new-err')[0], 'success context ok'); + equal(this[1], $(fx).find('.new-err')[1], 'success context2 ok'); equal(data.status, 500, 'status 500 ok'); equal(data.responseText, 'customtext', 'server error ok'); @@ -347,6 +347,9 @@ $(function () { e.remove(); e1.remove(); start(); + }, + error: function(errors) { + ok(false, 'error should not be called'); } }); diff --git a/test/unit/checklist.js b/test/unit/checklist.js index f94604a..96d404e 100644 --- a/test/unit/checklist.js +++ b/test/unit/checklist.js @@ -3,7 +3,8 @@ $(function () { module("checklist", { setup: function(){ sfx = $('#qunit-fixture'), - fx = $('#async-fixture'); + fx = $('#async-fixture'); + $.support.transition = false; } }); diff --git a/test/unit/date.js b/test/unit/date.js index ac25878..bb9701a 100644 --- a/test/unit/date.js +++ b/test/unit/date.js @@ -6,6 +6,7 @@ $(function () { setup: function(){ fx = $('#async-fixture'); dpg = $.fn.datepicker.DPGlobal; + $.support.transition = false; } }); diff --git a/test/unit/dateui.js b/test/unit/dateui.js index 5af7255..6fd592e 100644 --- a/test/unit/dateui.js +++ b/test/unit/dateui.js @@ -5,6 +5,7 @@ $(function () { module("dateui", { setup: function(){ fx = $('#async-fixture'); + $.support.transition = false; } });