提交 652098ad 编写于 作者: R RubaXa

+ QUnit

上级 54ec83bb
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
<title>Sortable :: Tests</title> <title>Sortable :: Tests</title>
</head> </head>
<body> <body>
<div id="canvas"> <div id="canvas">
<ul id="simple"> <ul id="simple">
<li>item 1</li> <li>item 1</li>
...@@ -17,11 +16,24 @@ ...@@ -17,11 +16,24 @@
</ul> </ul>
</div> </div>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<link rel="stylesheet" href="//code.jquery.com/qunit/qunit-1.21.0.css"/>
<script src="//code.jquery.com/qunit/qunit-1.21.0.js"></script>
<script src="./src/raf.js"></script> <script src="./src/raf.js"></script>
<script src="./src/simulate.js"></script> <script src="./src/simulate.js"></script>
<script src="./src/qunit.ext.js"></script>
<script src="../Sortable.js"></script> <script src="../Sortable.js"></script>
<script>
Sortable.create(simple);
</script>
<script src="./sortable.tests.js"></script> <script src="./sortable.tests.js"></script>
</body> </body>
</html> </html>
'use strict'; 'use strict';
Sortable.create(simple); QUnit.module('Sortable');
simulateDrag({ QUnit.sortableTest('simple', {
from: { from: {
el: '#simple', el: '#simple',
index: 0 index: 0
...@@ -12,6 +12,7 @@ simulateDrag({ ...@@ -12,6 +12,7 @@ simulateDrag({
el: '#simple', el: '#simple',
index: 'last' index: 'last'
} }
}, function () { }, function (assert, scope) {
assert.ok(scope.toList.contains(scope.target), 'container');
assert.equal(scope.target, scope.toList.lastElementChild, 'position');
}); });
(function () {
'use strict';
QUnit.sortableTest = function sortableTest(name, options, fn) {
QUnit.test(name, function (assert) {
var done = assert.async();
var data = simulateDrag(options, function () {
fn(assert, data, options);
done();
});
});
};
})();
...@@ -108,6 +108,12 @@ ...@@ -108,6 +108,12 @@
callback(); callback();
} }
}); });
return {
target: fromEl,
fromList: fromEl.parentNode,
toList: toEl.parentNode
};
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册