mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Merge remote-tracking branch 'ducksboard/bug-493-jquery-no-global-fail'
* ducksboard/bug-493-jquery-no-global-fail: Fix for bug #493 including unit tests to prove.
This commit is contained in:
@ -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",
|
||||
|
18
package.json
18
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"
|
||||
}
|
||||
}
|
||||
|
53
test/amd-main.js
Normal file
53
test/amd-main.js
Normal file
@ -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();
|
||||
}
|
||||
);
|
3
test/jquery-private.js
vendored
Normal file
3
test/jquery-private.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
define(['jquery'], function (jq) {
|
||||
return jq.noConflict( true );
|
||||
});
|
54
test/jquery.gridster-amd.html
Normal file
54
test/jquery.gridster-amd.html
Normal file
@ -0,0 +1,54 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>gridster.js AMD Test Suite</title>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="../dist/jquery.gridster.css">
|
||||
|
||||
<link rel="stylesheet" href="../libs/qunit/qunit/qunit.css" media="screen">
|
||||
<!-- Load requirejs which will load amd-main.js and start from there-->
|
||||
<script data-main="amd-main.js" src="../libs/requirejs/require.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">gridster.js AMD 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">
|
||||
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li data-row="1" data-col="1" data-sizex="2" data-sizey="2"></li>
|
||||
<li data-row="1" data-col="3" data-sizex="1" data-sizey="2"></li>
|
||||
<li data-row="1" data-col="4" data-sizex="1" data-sizey="1"></li>
|
||||
<li data-row="3" data-col="2" data-sizex="3" data-sizey="1"></li>
|
||||
|
||||
<li data-row="4" data-col="1" data-sizex="1" data-sizey="1"></li>
|
||||
<li data-row="3" data-col="1" data-sizex="1" data-sizey="1"></li>
|
||||
<li data-row="4" data-col="2" data-sizex="1" data-sizey="1"></li>
|
||||
<li data-row="5" data-col="2" data-sizex="1" data-sizey="1"></li>
|
||||
<li data-row="4" data-col="4" data-sizex="1" data-sizey="1"></li>
|
||||
|
||||
<li data-row="1" data-col="5" data-sizex="1" data-sizey="3"></li>
|
||||
|
||||
|
||||
<li data-row="5" data-col="1" data-sizex="1" data-sizey="2"></li>
|
||||
<li data-row="4" data-col="3" data-sizex="1" data-sizey="2"></li>
|
||||
<li data-row="5" data-col="4" data-sizex="1" data-sizey="1"></li>
|
||||
<li data-row="6" data-col="2" data-sizex="3" data-sizey="1"></li>
|
||||
|
||||
<li data-row="4" data-col="5" data-sizex="1" data-sizey="2"></li>
|
||||
<li data-row="6" data-col="5" data-sizex="1" data-sizey="1"></li>
|
||||
|
||||
<li data-row="7" data-col="3" data-sizex="1" data-sizey="1"></li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
@ -7,20 +7,15 @@
|
||||
<script src="../libs/jquery/jquery.js"></script>
|
||||
<script>jQuery.noConflict()</script>
|
||||
|
||||
|
||||
<script type="text/javascript" src="../libs/jquery/jquery.js"></script>
|
||||
|
||||
<script src="../dist/jquery.gridster.min.js" type="text/javascript" charset="utf-8"></script>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="../dist/jquery.gridster.css">
|
||||
|
||||
|
||||
<!-- Load local QUnit (grunt requires v1.0.0 or newer). -->
|
||||
<link rel="stylesheet" href="../libs/qunit/qunit.css" media="screen">
|
||||
<link rel="stylesheet" href="../libs/qunit/qunit/qunit.css" media="screen">
|
||||
|
||||
<script src="../libs/qunit/qunit.js"></script>
|
||||
<script src="../libs/qunit/qunit/qunit.js"></script>
|
||||
<!-- Load local lib and tests. -->
|
||||
<script src="../src/jquery.gridster.js"></script>
|
||||
<script src="jquery.gridster_test.js"></script>
|
||||
|
||||
</head>
|
@ -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));
|
28
test/testsuite.js
Normal file
28
test/testsuite.js
Normal file
@ -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');
|
||||
});
|
||||
}
|
||||
);
|
Reference in New Issue
Block a user