Skip to content
Permalink
Browse files

Dev: remove globals from tests and moved test helpers to correct loca…

…tion - Fixed #8770 Dev: Remove globals and Standardize Test Suite
  • Loading branch information...
mikesherov committed Nov 3, 2012
1 parent 68ad80c commit 3df9ea29e644a3dd6345161513dae5823d9b0460
Showing with 821 additions and 819 deletions.
  1. +0 −15 tests/.jshintrc
  2. +1 −0 tests/unit/datepicker/datepicker.html
  3. +53 −77 tests/unit/datepicker/datepicker_core.js
  4. +5 −5 tests/unit/datepicker/datepicker_events.js
  5. +19 −19 tests/unit/datepicker/datepicker_methods.js
  6. +108 −108 tests/unit/datepicker/datepicker_options.js
  7. +22 −0 tests/unit/datepicker/datepicker_test_helpers.js
  8. +4 −4 tests/unit/datepicker/datepicker_tickets.js
  9. +1 −0 tests/unit/dialog/dialog.html
  10. +10 −81 tests/unit/dialog/dialog_core.js
  11. +124 −114 tests/unit/dialog/dialog_events.js
  12. +16 −12 tests/unit/dialog/dialog_methods.js
  13. +96 −93 tests/unit/dialog/dialog_options.js
  14. +45 −0 tests/unit/dialog/dialog_test_helpers.js
  15. +18 −17 tests/unit/dialog/dialog_tickets.js
  16. +1 −0 tests/unit/draggable/draggable.html
  17. +8 −69 tests/unit/draggable/draggable_core.js
  18. +25 −19 tests/unit/draggable/draggable_events.js
  19. +10 −4 tests/unit/draggable/draggable_methods.js
  20. +118 −108 tests/unit/draggable/draggable_options.js
  21. +57 −0 tests/unit/draggable/draggable_test_helpers.js
  22. +1 −0 tests/unit/droppable/droppable.html
  23. +0 −11 tests/unit/droppable/droppable_core.js
  24. +10 −4 tests/unit/droppable/droppable_methods.js
  25. +2 −2 tests/unit/droppable/droppable_options.js
  26. +10 −0 tests/unit/droppable/droppable_test_helpers.js
  27. +1 −0 tests/unit/resizable/resizable.html
  28. +0 −16 tests/unit/resizable/resizable_core.js
  29. +15 −0 tests/unit/resizable/resizable_test_helpers.js
  30. +1 −0 tests/unit/selectable/selectable.html
  31. +1 −14 tests/unit/selectable/selectable_core.js
  32. +12 −0 tests/unit/selectable/selectable_test_helpers.js
  33. +1 −0 tests/unit/sortable/sortable.html
  34. +1 −17 tests/unit/sortable/sortable_core.js
  35. +10 −4 tests/unit/sortable/sortable_methods.js
  36. +9 −0 tests/unit/sortable/sortable_test_helpers.js
  37. +6 −6 tests/unit/sortable/sortable_tickets.js
@@ -14,35 +14,20 @@
"unused": true,
"predef": [
"asyncTest",
"container",
"deepEqual",
"d1",
"d2",
"dlg",
"domEqual",
"drag",
"dragged",
"el",
"equal",
"equalsDate",
"expect",
"Globalize",
"heightAfter",
"init",
"modal",
"module",
"moved",
"notEqual",
"offsetAfter",
"offsetBefore",
"ok",
"QUnit",
"start",
"strictEqual",
"stop",
"test",
"TestHelpers",
"widthAfter",
"JSHINT"
]
}
@@ -27,6 +27,7 @@
<script src="datepicker_events.js"></script>
<script src="datepicker_methods.js"></script>
<script src="datepicker_options.js"></script>
<script src="datepicker_test_helpers.js"></script>
<script src="datepicker_tickets.js"></script>

<script src="../swarminject.js"></script>

Large diffs are not rendered by default.

@@ -24,13 +24,13 @@ function callback2(year, month, inst) {
test('events', function() {
expect( 26 );
var dateStr, newMonthYear, inp2,
inp = init('#inp', {onSelect: callback}),
inp = TestHelpers.datepicker.init('#inp', {onSelect: callback}),
date = new Date();
// onSelect
inp.val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equal(selectedThis, inp[0], 'Callback selected this');
equal(selectedInst, $.data(inp[0], TestHelpers.PROP_NAME), 'Callback selected inst');
equal(selectedInst, $.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Callback selected inst');
equal(selectedDate, $.datepicker.formatDate('mm/dd/yy', date),
'Callback selected date');
inp.val('').datepicker('show').
@@ -59,7 +59,7 @@ test('events', function() {
inp.simulate('keydown', {keyCode: $.ui.keyCode.PAGE_UP});
date.setMonth(date.getMonth() - 1);
equal(selectedThis, inp[0], 'Callback change month/year this');
equal(selectedInst, $.data(inp[0], TestHelpers.PROP_NAME), 'Callback change month/year inst');
equal(selectedInst, $.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Callback change month/year inst');
equal(selectedDate, newMonthYear(date),
'Callback change month/year date - pgup');
inp.simulate('keydown', {keyCode: $.ui.keyCode.PAGE_DOWN});
@@ -107,7 +107,7 @@ test('events', function() {
val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE});
equal(selectedThis, inp[0], 'Callback close this');
equal(selectedInst, $.data(inp[0], TestHelpers.PROP_NAME), 'Callback close inst');
equal(selectedInst, $.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Callback close inst');
equal(selectedDate, '', 'Callback close date - esc');
inp.val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
@@ -120,7 +120,7 @@ test('events', function() {
simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.END});
equal(selectedDate, '', 'Callback close date - ctrl+end');

inp2 = init('#inp2');
inp2 = TestHelpers.datepicker.init('#inp2');
inp2.datepicker().datepicker('option', {onClose: callback}).datepicker('show');
inp.datepicker('show');
equal(selectedThis, inp2[0], 'Callback close this');
@@ -8,65 +8,65 @@ module("datepicker: methods");
test('destroy', function() {
expect( 33 );
var inl,
inp = init('#inp');
inp = TestHelpers.datepicker.init('#inp');
ok(inp.is('.hasDatepicker'), 'Default - marker class set');
ok($.data(inp[0], TestHelpers.PROP_NAME), 'Default - instance present');
ok($.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Default - instance present');
ok(inp.next().is('#alt'), 'Default - button absent');
inp.datepicker('destroy');
inp = $('#inp');
ok(!inp.is('.hasDatepicker'), 'Default - marker class cleared');
ok(!$.data(inp[0], TestHelpers.PROP_NAME), 'Default - instance absent');
ok(!$.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Default - instance absent');
ok(inp.next().is('#alt'), 'Default - button absent');
// With button
inp= init('#inp', {showOn: 'both'});
inp= TestHelpers.datepicker.init('#inp', {showOn: 'both'});
ok(inp.is('.hasDatepicker'), 'Button - marker class set');
ok($.data(inp[0], TestHelpers.PROP_NAME), 'Button - instance present');
ok($.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Button - instance present');
ok(inp.next().text() === '...', 'Button - button added');
inp.datepicker('destroy');
inp = $('#inp');
ok(!inp.is('.hasDatepicker'), 'Button - marker class cleared');
ok(!$.data(inp[0], TestHelpers.PROP_NAME), 'Button - instance absent');
ok(!$.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Button - instance absent');
ok(inp.next().is('#alt'), 'Button - button removed');
// With append text
inp = init('#inp', {appendText: 'Testing'});
inp = TestHelpers.datepicker.init('#inp', {appendText: 'Testing'});
ok(inp.is('.hasDatepicker'), 'Append - marker class set');
ok($.data(inp[0], TestHelpers.PROP_NAME), 'Append - instance present');
ok($.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Append - instance present');
ok(inp.next().text() === 'Testing', 'Append - append text added');
inp.datepicker('destroy');
inp = $('#inp');
ok(!inp.is('.hasDatepicker'), 'Append - marker class cleared');
ok(!$.data(inp[0], TestHelpers.PROP_NAME), 'Append - instance absent');
ok(!$.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Append - instance absent');
ok(inp.next().is('#alt'), 'Append - append text removed');
// With both
inp= init('#inp', {showOn: 'both', buttonImageOnly: true,
inp= TestHelpers.datepicker.init('#inp', {showOn: 'both', buttonImageOnly: true,
buttonImage: 'img/calendar.gif', appendText: 'Testing'});
ok(inp.is('.hasDatepicker'), 'Both - marker class set');
ok($.data(inp[0], TestHelpers.PROP_NAME), 'Both - instance present');
ok($.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Both - instance present');
ok(inp.next()[0].nodeName.toLowerCase() === 'img', 'Both - button added');
ok(inp.next().next().text() === 'Testing', 'Both - append text added');
inp.datepicker('destroy');
inp = $('#inp');
ok(!inp.is('.hasDatepicker'), 'Both - marker class cleared');
ok(!$.data(inp[0], TestHelpers.PROP_NAME), 'Both - instance absent');
ok(!$.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Both - instance absent');
ok(inp.next().is('#alt'), 'Both - button and append text absent');
// Inline
inl = init('#inl');
inl = TestHelpers.datepicker.init('#inl');
ok(inl.is('.hasDatepicker'), 'Inline - marker class set');
ok(inl.html() !== '', 'Inline - datepicker present');
ok($.data(inl[0], TestHelpers.PROP_NAME), 'Inline - instance present');
ok($.data(inl[0], TestHelpers.datepicker.PROP_NAME), 'Inline - instance present');
ok(inl.next().length === 0 || inl.next().is('p'), 'Inline - button absent');
inl.datepicker('destroy');
inl = $('#inl');
ok(!inl.is('.hasDatepicker'), 'Inline - marker class cleared');
ok(inl.html() === '', 'Inline - datepicker absent');
ok(!$.data(inl[0], TestHelpers.PROP_NAME), 'Inline - instance absent');
ok(!$.data(inl[0], TestHelpers.datepicker.PROP_NAME), 'Inline - instance absent');
ok(inl.next().length === 0 || inl.next().is('p'), 'Inline - button absent');
});

test('enableDisable', function() {
expect( 33 );
var inl, dp,
inp = init('#inp');
inp = TestHelpers.datepicker.init('#inp');
ok(!inp.datepicker('isDisabled'), 'Enable/disable - initially marked as enabled');
ok(!inp[0].disabled, 'Enable/disable - field initially enabled');
inp.datepicker('disable');
@@ -77,7 +77,7 @@ test('enableDisable', function() {
ok(!inp[0].disabled, 'Enable/disable - field now enabled');
inp.datepicker('destroy');
// With a button
inp = init('#inp', {showOn: 'button'});
inp = TestHelpers.datepicker.init('#inp', {showOn: 'button'});
ok(!inp.datepicker('isDisabled'), 'Enable/disable button - initially marked as enabled');
ok(!inp[0].disabled, 'Enable/disable button - field initially enabled');
ok(!inp.next('button')[0].disabled, 'Enable/disable button - button initially enabled');
@@ -91,7 +91,7 @@ test('enableDisable', function() {
ok(!inp.next('button')[0].disabled, 'Enable/disable button - button now enabled');
inp.datepicker('destroy');
// With an image button
inp = init('#inp', {showOn: 'button', buttonImageOnly: true,
inp = TestHelpers.datepicker.init('#inp', {showOn: 'button', buttonImageOnly: true,
buttonImage: 'img/calendar.gif'});
ok(!inp.datepicker('isDisabled'), 'Enable/disable image - initially marked as enabled');
ok(!inp[0].disabled, 'Enable/disable image - field initially enabled');
@@ -106,7 +106,7 @@ test('enableDisable', function() {
ok(parseFloat(inp.next('img').css('opacity')) === 1, 'Enable/disable image - image now enabled');
inp.datepicker('destroy');
// Inline
inl = init('#inl', {changeYear: true});
inl = TestHelpers.datepicker.init('#inl', {changeYear: true});
dp = $('.ui-datepicker-inline', inl);
ok(!inl.datepicker('isDisabled'), 'Enable/disable inline - initially marked as enabled');
ok(!dp.children().is('.ui-state-disabled'), 'Enable/disable inline - not visually disabled initially');

0 comments on commit 3df9ea2

Please sign in to comment.
You can’t perform that action at this time.