From 489160abd896aac7c140775207d18a3bf489c08f Mon Sep 17 00:00:00 2001 From: Paul Bakaus Date: Fri, 23 May 2008 09:23:30 +0000 Subject: --- ui/tests/accordion.html | 175 +++++++++++++++++++++++++++++++++++++ ui/tests/accordion.js | 78 +++++++++++++++++ ui/tests/all.html | 188 ++++++++++++++++++++++++++++++++++++++++ ui/tests/slider.html | 38 ++++++++ ui/tests/slider.js | 100 +++++++++++++++++++++ ui/tests/widgets/accordion.html | 175 ------------------------------------- ui/tests/widgets/accordion.js | 78 ----------------- ui/tests/widgets/all.html | 188 ---------------------------------------- ui/tests/widgets/slider.html | 38 -------- ui/tests/widgets/slider.js | 100 --------------------- 10 files changed, 579 insertions(+), 579 deletions(-) create mode 100644 ui/tests/accordion.html create mode 100644 ui/tests/accordion.js create mode 100644 ui/tests/all.html create mode 100644 ui/tests/slider.html create mode 100644 ui/tests/slider.js delete mode 100644 ui/tests/widgets/accordion.html delete mode 100644 ui/tests/widgets/accordion.js delete mode 100644 ui/tests/widgets/all.html delete mode 100644 ui/tests/widgets/slider.html delete mode 100644 ui/tests/widgets/slider.js diff --git a/ui/tests/accordion.html b/ui/tests/accordion.html new file mode 100644 index 000000000..5732bf966 --- /dev/null +++ b/ui/tests/accordion.html @@ -0,0 +1,175 @@ + + + + jQuery UI Accordion Test Suite + + + + + + + + + + + + + + + + + + + +

jQuery UI Accordion Test Suite

+ +

+ +
    + +
    + +
    + Standard, container is a div, header is h3 and content p + +
    + There is one obvious advantage: +
    +

    + You've seen it coming!
    + Buy now and get nothing for free!
    + Well, at least no free beer. Perhaps a bear, if you can afford it. +

    +
    + Now that you've got... +
    +

    + your bear, you have to admit it!
    + No, we aren't selling bears. +

    +

    + We could talk about renting one. +

    +
    + Rent one bear, ... +
    +

    + get two for three beer. +

    +

    + And now, for something completely different. +

    +
    +
    + +
    + +
    + Navigation - Unordered List with anchors and nested lists. +

    The first item is cloned to allow the user to select it. The + active element is choosen based on location.hash: Open Drums and click + the first item ('Drums'), then reload the page.

    + + + +
    + +
    + With options, container is a definition list, header dt, content dd + +
    +
    Red
    +
    + Fancy stuff about red thingies. +
    +
    Green
    +
    + Green! Green! Green! +
    +
    Blue
    +
    + Cool kids are blue. +
    +
    + +
    + +
    + Divitus structure, div container, div header (class title), div + content, no active on startup and can be completely closed + +
    +
    +
    Tennis
    +
    + One ball, two players. Lots of fun. +
    +
    +
    +
    Soccer
    +
    + One ball, 22 players. Lots of fun. +
    +
    +
    +
    Baseball
    +
    + Well, one ball, some guys running around, some guys hitting others with a stick.
    + Sounds like fun, doesn't it? +
    +
    + Well, apart from the running part. +
    +
    +
    + +
    + +
    + + + Activate via selector, eg. ':first' or 'a:first': +
    + +
    Log of the 2nd accordion
    +
    + + \ No newline at end of file diff --git a/ui/tests/accordion.js b/ui/tests/accordion.js new file mode 100644 index 000000000..792c104d4 --- /dev/null +++ b/ui/tests/accordion.js @@ -0,0 +1,78 @@ +module("accordion"); + +jQuery.ui.accordion.defaults.animated = false; + +function state(accordion) { + var args = $.makeArray(arguments).slice(1); + $.each(args, function(i, n) { + equals(n, accordion.find("div").eq(i).is(":visible")); + }); +} + +test("basics", function() { + state($('#list1').accordion(), 1, 0, 0); +}); + +test("autoheight", function() { + $('#navigation').accordion({ header: '.head', autoheight: false }); + equals( 90, $('#navigation ul:first').height() ); + equals( 126, $('#navigation ul:eq(1)').height() ); + equals( 54, $('#navigation ul:last').height() ); + $('#navigation').accordion("destroy").accordion({ header: '.head',autoheight: true }); + equals( 126, $('#navigation ul:first').height() ); + equals( 126, $('#navigation ul:eq(1)').height() ); + equals( 126, $('#navigation ul:last').height() ); +}); + +test("activate, numeric", function() { + var ac = $('#list1').accordion({ active: 1 }); + state(ac, 0, 1, 0); + ac.accordion("activate", 2); + state(ac, 0, 0, 1); + ac.accordion("activate", 0); + state(ac, 1, 0, 0); + ac.accordion("activate", 1); + state(ac, 0, 1, 0); + ac.accordion("activate", 2); + state(ac, 0, 0, 1); + ac.accordion("activate", -1); + state(ac, 0, 0, 1); +}); + +test("activate, boolean and numeric, alwaysOpen:false", function() { + var ac = $('#list1').accordion({alwaysOpen: false}).accordion("activate", 2); + state(ac, 0, 0, 1); + ok("x", "----") + ac.accordion("activate", 0); + state(ac, 1, 0, 0); + ok("x", "----") + ac.accordion("activate", -1); + state(ac, 0, 0, 0); +}); + +test("activate, boolean, alwaysOpen:true", function() { + var ac = $('#list1').accordion().accordion("activate", 2); + state(ac, 0, 0, 1); + ac.accordion("activate", -1); + state(ac, 0, 0, 1); +}); + +test("activate, string expression", function() { + var ac = $('#list1').accordion({ active: ":last" }); + state(ac, 0, 0, 1); + ac.accordion("activate", ":first"); + state(ac, 1, 0, 0); + ac.accordion("activate", ":eq(1)"); + state(ac, 0, 1, 0); + ac.accordion("activate", ":last"); + state(ac, 0, 0, 1); +}); + +test("activate, jQuery or DOM element", function() { + var ac = $('#list1').accordion({ active: $("#list1 a:last") }); + state(ac, 0, 0, 1); + ac.accordion("activate", $("#list1 a:first")); + state(ac, 1, 0, 0); + ac.accordion("activate", $("#list1 a")[1]); + state(ac, 0, 1, 0); +}); \ No newline at end of file diff --git a/ui/tests/all.html b/ui/tests/all.html new file mode 100644 index 000000000..dc70d650c --- /dev/null +++ b/ui/tests/all.html @@ -0,0 +1,188 @@ + + + + jQuery UI All Tests + + + + + + + + + + + + + + + + + + + + + +

    jQuery UI All Tests

    + +

    + +

    Run individual testsuites or doubleclick a test below

    + + +
      + +
      + +
      +
      +
      +
      + +
      + Standard, container is a div, header is h3 and content p + +
      + There is one obvious advantage: +
      +

      + You've seen it coming!
      + Buy now and get nothing for free!
      + Well, at least no free beer. Perhaps a bear, if you can afford it. +

      +
      + Now that you've got... +
      +

      + your bear, you have to admit it!
      + No, we aren't selling bears. +

      +

      + We could talk about renting one. +

      +
      + Rent one bear, ... +
      +

      + get two for three beer. +

      +

      + And now, for something completely different. +

      +
      +
      + +
      + +
      + Navigation - Unordered List with anchors and nested lists. +

      The first item is cloned to allow the user to select it. The + active element is choosen based on location.hash: Open Drums and click + the first item ('Drums'), then reload the page.

      + + + +
      + +
      + With options, container is a definition list, header dt, content dd + +
      +
      Red
      +
      + Fancy stuff about red thingies. +
      +
      Green
      +
      + Green! Green! Green! +
      +
      Blue
      +
      + Cool kids are blue. +
      +
      + +
      + +
      + Divitus structure, div container, div header (class title), div + content, no active on startup and can be completely closed + +
      +
      +
      Tennis
      +
      + One ball, two players. Lots of fun. +
      +
      +
      +
      Soccer
      +
      + One ball, 22 players. Lots of fun. +
      +
      +
      +
      Baseball
      +
      + Well, one ball, some guys running around, some guys hitting others with a stick.
      + Sounds like fun, doesn't it? +
      +
      + Well, apart from the running part. +
      +
      +
      + +
      + +
      + + + Activate via selector, eg. ':first' or 'a:first': +
      + +
      Log of the 2nd accordion
      +
      + + \ No newline at end of file diff --git a/ui/tests/slider.html b/ui/tests/slider.html new file mode 100644 index 000000000..858bd4929 --- /dev/null +++ b/ui/tests/slider.html @@ -0,0 +1,38 @@ + + + + + +Slider Test Page + + + + + + + + + + + + + + + + + +

      jQuery Test Suite

      + +

      + +
      +
      +
      +
      +
      +
      + +
        + + + diff --git a/ui/tests/slider.js b/ui/tests/slider.js new file mode 100644 index 000000000..035fa496f --- /dev/null +++ b/ui/tests/slider.js @@ -0,0 +1,100 @@ +$.fn.triggerKeydown = function(keyCode) { + return this.trigger("keydown", [$.event.fix({event:"keydown", keyCode: keyCode, target: this[0]})]); +} + +function assertChange(stepping, start, result, action) { + return function() { + expect(1); + var slider = $("#slider3").slider({ + stepping: stepping, + startValue: start, + min: 0, + max: 1000, + change: function(e, ui) { + equals(ui.value, result, "changed to " + ui.value); + } + }); + action.apply(slider); + } +} + +module("slider: single handle") + +test("change one step via keydown", assertChange(1, undefined, 1, function() { + this.find("a").triggerKeydown("39"); +})) +test("change - 10 steps via keydown", assertChange(10, 20, 10, function() { + this.find("a").triggerKeydown("37"); +})) +test("change +10 steps via keydown", assertChange(10, 20, 30, function() { + this.find("a").triggerKeydown("39"); +})) + +test("moveTo, absolute value", assertChange(1, 1, 10, function() { + this.slider("moveTo", 10); +})) + +test("moveTo, absolute value as string", assertChange(1, 1, 10, function() { + this.slider("moveTo", "10"); +})) + +test("moveTo, absolute value, below min", assertChange(1, 1, 0, function() { + this.slider("moveTo", -10); +})) + +test("moveTo, relative positive value", assertChange(1, 1, 11, function() { + this.slider("moveTo", "+=10"); +})) + +test("moveTo, relative positive value, above max", assertChange(1, 10, 1000, function() { + this.slider("moveTo", "+=2000"); +})) + +test("moveTo, relative negative value", assertChange(1, 20, 10, function() { + this.slider("moveTo", "-=10"); +})) + +test("options update min/max", function() { + expect(2); + var slider = $("#slider3").slider({ + stepping: 1, + startValue: 1 + }); + slider.slider("moveTo", "-=10"); + equals(slider.slider("value"), 0); + slider.data("min.slider", -10); + slider.slider("moveTo", "-=20"); + equals(slider.slider("value"), -10); +}) + +module("slider: setup and teardown"); + +test("destroy and recreate", function() { + expect(3) + var slider = $("#slider3").slider(); + slider.slider("moveTo", "+=20"); + equals(slider.slider("value"), 20); + slider.slider("destroy"); + + slider.slider("moveTo", "+=30"); + ok(true, "nothing happens after slider is destroyed"); + + slider.slider().slider("moveTo", "30"); + + equals(Math.round(slider.slider("value")), 30); +}) + +test("handle creation", function() { + var slider = $("#slider1"); + equals(slider.children().size(), 0); + slider.slider({ + handles: [ + { start: 0 }, + { start: 10 } + ] + }); + equals(slider.children().size(), 2); + var instance = $.data(slider[0], "slider") + equals(instance.handle.length, 2); + ok(instance.handle.jquery, "handle must be a jquery object") +}) \ No newline at end of file diff --git a/ui/tests/widgets/accordion.html b/ui/tests/widgets/accordion.html deleted file mode 100644 index 5732bf966..000000000 --- a/ui/tests/widgets/accordion.html +++ /dev/null @@ -1,175 +0,0 @@ - - - - jQuery UI Accordion Test Suite - - - - - - - - - - - - - - - - - - - -

        jQuery UI Accordion Test Suite

        - -

        - -
          - -
          - -
          - Standard, container is a div, header is h3 and content p - -
          - There is one obvious advantage: -
          -

          - You've seen it coming!
          - Buy now and get nothing for free!
          - Well, at least no free beer. Perhaps a bear, if you can afford it. -

          -
          - Now that you've got... -
          -

          - your bear, you have to admit it!
          - No, we aren't selling bears. -

          -

          - We could talk about renting one. -

          -
          - Rent one bear, ... -
          -

          - get two for three beer. -

          -

          - And now, for something completely different. -

          -
          -
          - -
          - -
          - Navigation - Unordered List with anchors and nested lists. -

          The first item is cloned to allow the user to select it. The - active element is choosen based on location.hash: Open Drums and click - the first item ('Drums'), then reload the page.

          - - - -
          - -
          - With options, container is a definition list, header dt, content dd - -
          -
          Red
          -
          - Fancy stuff about red thingies. -
          -
          Green
          -
          - Green! Green! Green! -
          -
          Blue
          -
          - Cool kids are blue. -
          -
          - -
          - -
          - Divitus structure, div container, div header (class title), div - content, no active on startup and can be completely closed - -
          -
          -
          Tennis
          -
          - One ball, two players. Lots of fun. -
          -
          -
          -
          Soccer
          -
          - One ball, 22 players. Lots of fun. -
          -
          -
          -
          Baseball
          -
          - Well, one ball, some guys running around, some guys hitting others with a stick.
          - Sounds like fun, doesn't it? -
          -
          - Well, apart from the running part. -
          -
          -
          - -
          - -
          - - - Activate via selector, eg. ':first' or 'a:first': -
          - -
          Log of the 2nd accordion
          -
          - - \ No newline at end of file diff --git a/ui/tests/widgets/accordion.js b/ui/tests/widgets/accordion.js deleted file mode 100644 index 792c104d4..000000000 --- a/ui/tests/widgets/accordion.js +++ /dev/null @@ -1,78 +0,0 @@ -module("accordion"); - -jQuery.ui.accordion.defaults.animated = false; - -function state(accordion) { - var args = $.makeArray(arguments).slice(1); - $.each(args, function(i, n) { - equals(n, accordion.find("div").eq(i).is(":visible")); - }); -} - -test("basics", function() { - state($('#list1').accordion(), 1, 0, 0); -}); - -test("autoheight", function() { - $('#navigation').accordion({ header: '.head', autoheight: false }); - equals( 90, $('#navigation ul:first').height() ); - equals( 126, $('#navigation ul:eq(1)').height() ); - equals( 54, $('#navigation ul:last').height() ); - $('#navigation').accordion("destroy").accordion({ header: '.head',autoheight: true }); - equals( 126, $('#navigation ul:first').height() ); - equals( 126, $('#navigation ul:eq(1)').height() ); - equals( 126, $('#navigation ul:last').height() ); -}); - -test("activate, numeric", function() { - var ac = $('#list1').accordion({ active: 1 }); - state(ac, 0, 1, 0); - ac.accordion("activate", 2); - state(ac, 0, 0, 1); - ac.accordion("activate", 0); - state(ac, 1, 0, 0); - ac.accordion("activate", 1); - state(ac, 0, 1, 0); - ac.accordion("activate", 2); - state(ac, 0, 0, 1); - ac.accordion("activate", -1); - state(ac, 0, 0, 1); -}); - -test("activate, boolean and numeric, alwaysOpen:false", function() { - var ac = $('#list1').accordion({alwaysOpen: false}).accordion("activate", 2); - state(ac, 0, 0, 1); - ok("x", "----") - ac.accordion("activate", 0); - state(ac, 1, 0, 0); - ok("x", "----") - ac.accordion("activate", -1); - state(ac, 0, 0, 0); -}); - -test("activate, boolean, alwaysOpen:true", function() { - var ac = $('#list1').accordion().accordion("activate", 2); - state(ac, 0, 0, 1); - ac.accordion("activate", -1); - state(ac, 0, 0, 1); -}); - -test("activate, string expression", function() { - var ac = $('#list1').accordion({ active: ":last" }); - state(ac, 0, 0, 1); - ac.accordion("activate", ":first"); - state(ac, 1, 0, 0); - ac.accordion("activate", ":eq(1)"); - state(ac, 0, 1, 0); - ac.accordion("activate", ":last"); - state(ac, 0, 0, 1); -}); - -test("activate, jQuery or DOM element", function() { - var ac = $('#list1').accordion({ active: $("#list1 a:last") }); - state(ac, 0, 0, 1); - ac.accordion("activate", $("#list1 a:first")); - state(ac, 1, 0, 0); - ac.accordion("activate", $("#list1 a")[1]); - state(ac, 0, 1, 0); -}); \ No newline at end of file diff --git a/ui/tests/widgets/all.html b/ui/tests/widgets/all.html deleted file mode 100644 index dc70d650c..000000000 --- a/ui/tests/widgets/all.html +++ /dev/null @@ -1,188 +0,0 @@ - - - - jQuery UI All Tests - - - - - - - - - - - - - - - - - - - - - -

          jQuery UI All Tests

          - -

          - -

          Run individual testsuites or doubleclick a test below

          - - -
            - -
            - -
            -
            -
            -
            - -
            - Standard, container is a div, header is h3 and content p - -
            - There is one obvious advantage: -
            -

            - You've seen it coming!
            - Buy now and get nothing for free!
            - Well, at least no free beer. Perhaps a bear, if you can afford it. -

            -
            - Now that you've got... -
            -

            - your bear, you have to admit it!
            - No, we aren't selling bears. -

            -

            - We could talk about renting one. -

            -
            - Rent one bear, ... -
            -

            - get two for three beer. -

            -

            - And now, for something completely different. -

            -
            -
            - -
            - -
            - Navigation - Unordered List with anchors and nested lists. -

            The first item is cloned to allow the user to select it. The - active element is choosen based on location.hash: Open Drums and click - the first item ('Drums'), then reload the page.

            - - - -
            - -
            - With options, container is a definition list, header dt, content dd - -
            -
            Red
            -
            - Fancy stuff about red thingies. -
            -
            Green
            -
            - Green! Green! Green! -
            -
            Blue
            -
            - Cool kids are blue. -
            -
            - -
            - -
            - Divitus structure, div container, div header (class title), div - content, no active on startup and can be completely closed - -
            -
            -
            Tennis
            -
            - One ball, two players. Lots of fun. -
            -
            -
            -
            Soccer
            -
            - One ball, 22 players. Lots of fun. -
            -
            -
            -
            Baseball
            -
            - Well, one ball, some guys running around, some guys hitting others with a stick.
            - Sounds like fun, doesn't it? -
            -
            - Well, apart from the running part. -
            -
            -
            - -
            - -
            - - - Activate via selector, eg. ':first' or 'a:first': -
            - -
            Log of the 2nd accordion
            -
            - - \ No newline at end of file diff --git a/ui/tests/widgets/slider.html b/ui/tests/widgets/slider.html deleted file mode 100644 index 858bd4929..000000000 --- a/ui/tests/widgets/slider.html +++ /dev/null @@ -1,38 +0,0 @@ - - - - - -Slider Test Page - - - - - - - - - - - - - - - - - -

            jQuery Test Suite

            - -

            - -
            -
            -
            -
            -
            -
            - -
              - - - diff --git a/ui/tests/widgets/slider.js b/ui/tests/widgets/slider.js deleted file mode 100644 index 035fa496f..000000000 --- a/ui/tests/widgets/slider.js +++ /dev/null @@ -1,100 +0,0 @@ -$.fn.triggerKeydown = function(keyCode) { - return this.trigger("keydown", [$.event.fix({event:"keydown", keyCode: keyCode, target: this[0]})]); -} - -function assertChange(stepping, start, result, action) { - return function() { - expect(1); - var slider = $("#slider3").slider({ - stepping: stepping, - startValue: start, - min: 0, - max: 1000, - change: function(e, ui) { - equals(ui.value, result, "changed to " + ui.value); - } - }); - action.apply(slider); - } -} - -module("slider: single handle") - -test("change one step via keydown", assertChange(1, undefined, 1, function() { - this.find("a").triggerKeydown("39"); -})) -test("change - 10 steps via keydown", assertChange(10, 20, 10, function() { - this.find("a").triggerKeydown("37"); -})) -test("change +10 steps via keydown", assertChange(10, 20, 30, function() { - this.find("a").triggerKeydown("39"); -})) - -test("moveTo, absolute value", assertChange(1, 1, 10, function() { - this.slider("moveTo", 10); -})) - -test("moveTo, absolute value as string", assertChange(1, 1, 10, function() { - this.slider("moveTo", "10"); -})) - -test("moveTo, absolute value, below min", assertChange(1, 1, 0, function() { - this.slider("moveTo", -10); -})) - -test("moveTo, relative positive value", assertChange(1, 1, 11, function() { - this.slider("moveTo", "+=10"); -})) - -test("moveTo, relative positive value, above max", assertChange(1, 10, 1000, function() { - this.slider("moveTo", "+=2000"); -})) - -test("moveTo, relative negative value", assertChange(1, 20, 10, function() { - this.slider("moveTo", "-=10"); -})) - -test("options update min/max", function() { - expect(2); - var slider = $("#slider3").slider({ - stepping: 1, - startValue: 1 - }); - slider.slider("moveTo", "-=10"); - equals(slider.slider("value"), 0); - slider.data("min.slider", -10); - slider.slider("moveTo", "-=20"); - equals(slider.slider("value"), -10); -}) - -module("slider: setup and teardown"); - -test("destroy and recreate", function() { - expect(3) - var slider = $("#slider3").slider(); - slider.slider("moveTo", "+=20"); - equals(slider.slider("value"), 20); - slider.slider("destroy"); - - slider.slider("moveTo", "+=30"); - ok(true, "nothing happens after slider is destroyed"); - - slider.slider().slider("moveTo", "30"); - - equals(Math.round(slider.slider("value")), 30); -}) - -test("handle creation", function() { - var slider = $("#slider1"); - equals(slider.children().size(), 0); - slider.slider({ - handles: [ - { start: 0 }, - { start: 10 } - ] - }); - equals(slider.children().size(), 2); - var instance = $.data(slider[0], "slider") - equals(instance.handle.length, 2); - ok(instance.handle.jquery, "handle must be a jquery object") -}) \ No newline at end of file -- cgit v1.2.3