From 75ad7e4bd7d69243e7e5281c2642f00478fb072d Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Wed, 19 Feb 2014 18:02:09 +0200 Subject: Added tags, jquery UI --- .../it/static/js/ui/tests/unit/selectable/all.html | 30 ++++++ .../js/ui/tests/unit/selectable/selectable.html | 51 ++++++++++ .../ui/tests/unit/selectable/selectable_common.js | 21 +++++ .../js/ui/tests/unit/selectable/selectable_core.js | 3 + .../ui/tests/unit/selectable/selectable_events.js | 69 ++++++++++++++ .../ui/tests/unit/selectable/selectable_methods.js | 104 +++++++++++++++++++++ .../ui/tests/unit/selectable/selectable_options.js | 65 +++++++++++++ 7 files changed, 343 insertions(+) create mode 100644 apps/it/static/js/ui/tests/unit/selectable/all.html create mode 100644 apps/it/static/js/ui/tests/unit/selectable/selectable.html create mode 100644 apps/it/static/js/ui/tests/unit/selectable/selectable_common.js create mode 100644 apps/it/static/js/ui/tests/unit/selectable/selectable_core.js create mode 100644 apps/it/static/js/ui/tests/unit/selectable/selectable_events.js create mode 100644 apps/it/static/js/ui/tests/unit/selectable/selectable_methods.js create mode 100644 apps/it/static/js/ui/tests/unit/selectable/selectable_options.js (limited to 'apps/it/static/js/ui/tests/unit/selectable') diff --git a/apps/it/static/js/ui/tests/unit/selectable/all.html b/apps/it/static/js/ui/tests/unit/selectable/all.html new file mode 100644 index 0000000..5ee323f --- /dev/null +++ b/apps/it/static/js/ui/tests/unit/selectable/all.html @@ -0,0 +1,30 @@ + + + + + jQuery UI Selectable Test Suite + + + + + + + + + + + + + +

jQuery UI Selectable Test Suite

+

+
+

+
    +
    + +
    + + diff --git a/apps/it/static/js/ui/tests/unit/selectable/selectable.html b/apps/it/static/js/ui/tests/unit/selectable/selectable.html new file mode 100644 index 0000000..18ffc6e --- /dev/null +++ b/apps/it/static/js/ui/tests/unit/selectable/selectable.html @@ -0,0 +1,51 @@ + + + + + jQuery UI Selectable Test Suite + + + + + + + + + + + + + + + + + + +

    jQuery UI Selectable Test Suite

    +

    +
    +

    +
      +
      + + + +
      + + diff --git a/apps/it/static/js/ui/tests/unit/selectable/selectable_common.js b/apps/it/static/js/ui/tests/unit/selectable/selectable_common.js new file mode 100644 index 0000000..d00a47b --- /dev/null +++ b/apps/it/static/js/ui/tests/unit/selectable/selectable_common.js @@ -0,0 +1,21 @@ +TestHelpers.commonWidgetTests("selectable", { + defaults: { + appendTo: "body", + autoRefresh: true, + cancel: "input,textarea,button,select,option", + delay: 0, + disabled: false, + distance: 0, + filter: "*", + tolerance: "touch", + + // callbacks + create: null, + selected: null, + selecting: null, + start: null, + stop: null, + unselected: null, + unselecting: null + } +}); diff --git a/apps/it/static/js/ui/tests/unit/selectable/selectable_core.js b/apps/it/static/js/ui/tests/unit/selectable/selectable_core.js new file mode 100644 index 0000000..9953b6c --- /dev/null +++ b/apps/it/static/js/ui/tests/unit/selectable/selectable_core.js @@ -0,0 +1,3 @@ +/* + * selectable_core.js + */ \ No newline at end of file diff --git a/apps/it/static/js/ui/tests/unit/selectable/selectable_events.js b/apps/it/static/js/ui/tests/unit/selectable/selectable_events.js new file mode 100644 index 0000000..ae35fa3 --- /dev/null +++ b/apps/it/static/js/ui/tests/unit/selectable/selectable_events.js @@ -0,0 +1,69 @@ +/* + * selectable_events.js + */ +(function( $ ) { + +module("selectable: events"); + +test( "start", function() { + expect( 2 ); + var el = $("#selectable1"); + el.selectable({ + start: function() { + ok( true, "drag fired start callback" ); + equal( this, el[0], "context of callback" ); + } + }); + el.simulate( "drag", { + dx: 20, + dy: 20 + }); +}); + +test( "stop", function() { + expect( 2 ); + var el = $("#selectable1"); + el.selectable({ + start: function() { + ok( true, "drag fired stop callback" ); + equal( this, el[0], "context of callback" ); + } + }); + el.simulate( "drag", { + dx: 20, + dy: 20 + }); +}); + +test( "mousedown: initial position of helper", function() { + expect( 2 ); + + var helperOffset, + element = $( "#selectable1" ).selectable(), + contentToForceScroll = $( "
      " ).css({ + height: "10000px", + width: "10000px" + }); + + contentToForceScroll.appendTo( "body" ); + $( window ).scrollTop( 100 ).scrollLeft( 100 ); + + element.simulate( "mousedown", { + clientX: 10, + clientY: 10 + }); + + // we do a GTE comparison here because IE7 erroneously subtracts + // 2 pixels from a simulated mousedown for clientX/Y + // Support: IE7 + helperOffset = $( ".ui-selectable-helper" ).offset(); + ok( helperOffset.top >= 99, "Scroll top should be accounted for." ); + ok( helperOffset.left >= 99, "Scroll left should be accounted for." ); + + // Cleanup + element.simulate( "mouseup" ); + contentToForceScroll.remove(); + $( window ).scrollTop( 0 ).scrollLeft( 0 ); +}); + +})( jQuery ); diff --git a/apps/it/static/js/ui/tests/unit/selectable/selectable_methods.js b/apps/it/static/js/ui/tests/unit/selectable/selectable_methods.js new file mode 100644 index 0000000..72f9bb2 --- /dev/null +++ b/apps/it/static/js/ui/tests/unit/selectable/selectable_methods.js @@ -0,0 +1,104 @@ +/* + * selectable_methods.js + */ +(function($) { + +module("selectable: methods"); + +test("init", function() { + expect( 5 ); + + $("
      ").appendTo("body").selectable().remove(); + ok(true, ".selectable() called on element"); + + $([]).selectable().remove(); + ok(true, ".selectable() called on empty collection"); + + $("
      ").selectable().remove(); + ok(true, ".selectable() called on disconnected DOMElement"); + + var el = $("
      ").selectable(); + el.selectable("option", "foo"); + el.remove(); + ok(true, "arbitrary option getter after init"); + + $("
      ").selectable().selectable("option", "foo", "bar").remove(); + ok(true, "arbitrary option setter after init"); +}); + +test("destroy", function() { + expect( 4 ); + + $("
      ").appendTo("body").selectable().selectable("destroy").remove(); + ok(true, ".selectable('destroy') called on element"); + + $([]).selectable().selectable("destroy").remove(); + ok(true, ".selectable('destroy') called on empty collection"); + + $("
      ").selectable().selectable("destroy").remove(); + ok(true, ".selectable('destroy') called on disconnected DOMElement"); + + var expected = $("
      ").selectable(), + actual = expected.selectable("destroy"); + equal(actual, expected, "destroy is chainable"); +}); + +test("enable", function() { + expect(3); + var expected, actual, + fired = false, + el = $("#selectable1"); + + el.selectable({ + disabled: true, + start: function() { fired = true; } + }); + el.simulate( "drag", { + dx: 20, + dy: 20 + }); + equal(fired, false, "start fired"); + el.selectable("enable"); + el.simulate( "drag", { + dx: 20, + dy: 20 + }); + equal(fired, true, "start fired"); + el.selectable("destroy"); + + expected = $("
      ").selectable(); + actual = expected.selectable("enable"); + equal(actual, expected, "enable is chainable"); +}); + +test("disable", function() { + expect(3); + var expected, actual, + fired = false, + el = $("#selectable1"); + + el.selectable({ + disabled: false, + start: function() { fired = true; } + }); + el.simulate( "drag", { + dx: 20, + dy: 20 + }); + equal(fired, true, "start fired"); + el.selectable("disable"); + fired = false; + + el.simulate( "drag", { + dx: 20, + dy: 20 + }); + equal(fired, false, "start fired"); + el.selectable("destroy"); + + expected = $("
      ").selectable(); + actual = expected.selectable("disable"); + equal(actual, expected, "disable is chainable"); +}); + +})(jQuery); diff --git a/apps/it/static/js/ui/tests/unit/selectable/selectable_options.js b/apps/it/static/js/ui/tests/unit/selectable/selectable_options.js new file mode 100644 index 0000000..973247f --- /dev/null +++ b/apps/it/static/js/ui/tests/unit/selectable/selectable_options.js @@ -0,0 +1,65 @@ +/* + * selectable_options.js + */ +(function($) { + +module("selectable: options"); + +test("autoRefresh", function() { + expect(3); + + var actual = 0, + el = $("#selectable1"), + sel = $("*", el), + selected = function() { actual += 1; }; + + el = $("#selectable1").selectable({ autoRefresh: false, selected: selected }); + sel.hide(); + el.simulate( "drag", { + dx: 1000, + dy: 1000 + }); + equal(actual, sel.length); + el.selectable("destroy"); + + actual = 0; + sel.show(); + el = $("#selectable1").selectable({ autoRefresh: true, selected: selected }); + sel.hide(); + el.simulate( "drag", { + dx: 1000, + dy: 1000 + }); + equal(actual, 0); + + sel.show(); + $( sel[ 0 ] ).simulate( "drag", { + dx: 1000, + dy: 1000 + }); + equal(actual, sel.length); + + el.selectable("destroy"); + sel.show(); +}); + +test("filter", function() { + expect(2); + + var actual =0, + el = $("#selectable1"), + sel = $("*", el), + selected = function() { actual += 1; }; + + + el = $("#selectable1").selectable({ filter: ".special", selected: selected }); + el.simulate( "drag", { + dx: 1000, + dy: 1000 + }); + ok(sel.length !== 1, "this test assumes more than 1 selectee"); + equal(actual, 1); + el.selectable("destroy"); +}); + +})(jQuery); -- cgit v1.2.3