diff --git a/bower.json b/bower.json index 0bac368d1..eda66e71f 100644 --- a/bower.json +++ b/bower.json @@ -3,7 +3,9 @@ "homepage": "https://github.com/DecksterTeam/gridster.js", "version": "0.6.5", "dependencies": { - "jquery": "~1.11.2" + "jquery": "#2.0.3", + "requirejs": "^2.1.17", + "qunit": "~1.18.0" }, "main": [ "dist/jquery.gridster.js", @@ -19,4 +21,4 @@ "src/", "test/" ] -} \ No newline at end of file +} diff --git a/package.json b/package.json index 9d4f54137..ef469931f 100644 --- a/package.json +++ b/package.json @@ -13,20 +13,16 @@ "url": "git://github.com/DecksterTeam/gridster.js.git" }, "keywords": [], - "dependencies": { - "jquery": "git+https://github.com/jquery/jquery.git#2.0.3" - }, "devDependencies": { - "grunt": "~0.4.1", - "grunt-contrib-uglify": "~0.2.0", - "grunt-contrib-jshint": "~0.3.0", - "grunt-contrib-concat": "~0.1.3", - "grunt-contrib-watch": "~0.3.1", - "grunt-contrib-cssmin": "~0.5.0", - "grunt-contrib-yuidoc": "~0.4.0", "bower": "~0.9.2", - "qunitjs": "~1.11.0", + "grunt": "~0.4.1", "grunt-bump": "0.0.11", + "grunt-contrib-concat": "~0.1.3", + "grunt-contrib-cssmin": "~0.5.0", + "grunt-contrib-jshint": "~0.3.0", + "grunt-contrib-uglify": "~0.2.0", + "grunt-contrib-watch": "~0.3.1", + "grunt-contrib-yuidoc": "~0.4.0", "grunt-conventional-changelog": "~1.0.0" } } diff --git a/test/amd-main.js b/test/amd-main.js new file mode 100644 index 000000000..db14b1dff --- /dev/null +++ b/test/amd-main.js @@ -0,0 +1,53 @@ +//Based on https://github.com/jonnyreeves/qunit-require +/* global require */ +"use strict"; +require.config({ + //set the baseUrl to the src dir so that gridster + //AMD modules can be found. + baseUrl: '../src/', + paths: { + 'QUnit': '../libs/qunit/qunit/qunit', + 'jquery': '../libs/jquery/jquery', + 'gridster': 'jquery.gridster' + }, + map: { + // '*' means all modules will get 'jquery-private' + // for their 'jquery' dependency. + '*': { 'jquery': '../test/jquery-private' }, + + // 'jquery-private' wants the real jQuery module + // though. If this line was not here, there would + // be an unresolvable cyclic dependency. + '../test/jquery-private': { 'jquery': 'jquery' } + }, + shim: { + 'QUnit': { + exports: 'QUnit', + init: function() { + QUnit.config.autoload = false; + QUnit.config.autostart = false; + } + } + } +}); +/* + Load all of our require'd files + + We have to load all of the gridster jquery.* modules so + that they are defined for when gridster needs them. + + Lastly, load the testsuite which defines some tests. +*/ +require([ + 'QUnit', + 'utils', + 'jquery.coords', + 'jquery.collision', + 'jquery.draggable', + '../test/testsuite' + //Require'd files are passed as args, but we don't use them. +], function(QUnit/*, utils, coords, collision, draggable, testsuite*/) { + QUnit.load(); + QUnit.start(); + } +); diff --git a/test/jquery-private.js b/test/jquery-private.js new file mode 100644 index 000000000..6d6060ad0 --- /dev/null +++ b/test/jquery-private.js @@ -0,0 +1,3 @@ +define(['jquery'], function (jq) { + return jq.noConflict( true ); +}); diff --git a/test/jquery.gridster-amd.html b/test/jquery.gridster-amd.html new file mode 100644 index 000000000..6a6058798 --- /dev/null +++ b/test/jquery.gridster-amd.html @@ -0,0 +1,54 @@ + + + + + gridster.js AMD Test Suite + + + + + + + + + +

gridster.js AMD Test Suite

+

+
+

+
    +
    + +
    + +
    +
    + + + + diff --git a/test/jquery.gridder.html b/test/jquery.gridster.html similarity index 89% rename from test/jquery.gridder.html rename to test/jquery.gridster.html index 1750f0a4d..28acac61e 100644 --- a/test/jquery.gridder.html +++ b/test/jquery.gridster.html @@ -7,20 +7,15 @@ - - - - - + - + - diff --git a/test/jquery.gridder_test.js b/test/jquery.gridster_test.js similarity index 84% rename from test/jquery.gridder_test.js rename to test/jquery.gridster_test.js index 2df25e775..5ad67ce8f 100644 --- a/test/jquery.gridder_test.js +++ b/test/jquery.gridster_test.js @@ -30,9 +30,9 @@ } }); - // test('is chainable', 1, function() { - // // Not a bad test to run on collection methods. - // strictEqual(this.el, this.el.gridster(), 'should be chaninable'); - // }); + test('is chainable', function() { + // Not a bad test to run on collection methods. + strictEqual(this.el, this.el.gridster(), 'should be chaninable'); + }); }(jQuery)); diff --git a/test/testsuite.js b/test/testsuite.js new file mode 100644 index 000000000..86a00906f --- /dev/null +++ b/test/testsuite.js @@ -0,0 +1,28 @@ +/* global require */ +"use strict"; +define([ + 'QUnit', + 'jquery', + 'gridster' +], function(QUnit, $, gridster) { + + QUnit.module("Gridster AMD", { + setup: function () { + }, + teardown: function () { + } + }); + + QUnit.test('window.$ should be undefined.', function() { + equal(typeof window.$, 'undefined', 'window.$ should be undefined'); + equal(typeof window.jQuery, 'undefined', 'window.jQuery should be undefined'); + }); + + + QUnit.test('gridster should be initialized.', function() { + $('.wrapper ul').gridster(); + equal($(".wrapper").hasClass('ready'), true, 'Gridster should initialized wrapper.'); + equal($(".wrapper ul li").length, $(".gs-w").length, 'grid elements get a .gs-w class'); + }); + } +);