From 02afd8a32edb13ea7fc2266ac80092ea15c0930c Mon Sep 17 00:00:00 2001 From: Alvin Li Date: Wed, 9 Oct 2013 15:52:53 +0800 Subject: * treat 'apps/utils' as regular django app; which used to store general tools for used in other apps * moved 'templatetags' from 'apps/indicator' to 'apps/utils' * '.gitignore' to ignore 'fixtures_bak' * moved js plugins from 'apps/indicator/static/plugins' to 'staticfiles/plugins' apps/recommend: * updated 'recommend.models'; o commented 'recommend.models.ResearchCombination' (not used) * implemented views 'add_edit_blog_info' and 'ajax_add_edit_configs'; * added pages 'templates/recommend/add_edit_blog_info.html', 'add_edit_blog_info_error.html'; o related css and javascripts files * added 'tools.py'; * added 'utils/tools.py' for placing generic functions; * deleted 'initial_data.json' (mv 'fixtures' to 'fixtures_bak'); * small fixes to 'indicator.models', 'sciblog.models' and 'sfaccount.views' * fixed automatically show 'proper_nouns' annotation in blog: recovered the line 'import signals' in 'sciblog.models' * added 'is_ok()' method for 'recommend.models.ResearchConfig'; --- .../jquery-ui/tests/unit/accordion/accordion.html | 143 +++++++ .../tests/unit/accordion/accordion_common.js | 20 + .../tests/unit/accordion/accordion_core.js | 117 ++++++ .../tests/unit/accordion/accordion_events.js | 169 ++++++++ .../tests/unit/accordion/accordion_methods.js | 126 ++++++ .../tests/unit/accordion/accordion_options.js | 463 +++++++++++++++++++++ .../tests/unit/accordion/accordion_test_helpers.js | 27 ++ .../jquery-ui/tests/unit/accordion/all.html | 30 ++ 8 files changed, 1095 insertions(+) create mode 100644 97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion/accordion.html create mode 100644 97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion/accordion_common.js create mode 100644 97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion/accordion_core.js create mode 100644 97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion/accordion_events.js create mode 100644 97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion/accordion_methods.js create mode 100644 97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion/accordion_options.js create mode 100644 97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion/accordion_test_helpers.js create mode 100644 97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion/all.html (limited to '97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion') diff --git a/97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion/accordion.html b/97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion/accordion.html new file mode 100644 index 0000000..67928fd --- /dev/null +++ b/97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion/accordion.html @@ -0,0 +1,143 @@ + + + + + jQuery UI Accordion Test Suite + + + + + + + + + + + + + + + + + + + +

jQuery UI Accordion Test Suite

+

+
+

+
    +
    + +
    +

    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. +

    +
    +
    + + + +
    +
    + Accordion Header 1 +
    +
    + Accordion Content 1 +
    +
    + Accordion Header 2 +
    +
    + Accordion Content 2 +
    +
    + Accordion Header 3 +
    +
    + Accordion Content 3 +
    +
    + +
    + + diff --git a/97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion/accordion_common.js b/97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion/accordion_common.js new file mode 100644 index 0000000..ef24cf2 --- /dev/null +++ b/97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion/accordion_common.js @@ -0,0 +1,20 @@ +TestHelpers.commonWidgetTests( "accordion", { + defaults: { + active: 0, + animate: {}, + collapsible: false, + disabled: false, + event: "click", + header: "> li > :first-child,> :not(li):even", + heightStyle: "auto", + icons: { + "activeHeader": "ui-icon-triangle-1-s", + "header": "ui-icon-triangle-1-e" + }, + + // callbacks + activate: null, + beforeActivate: null, + create: null + } +}); diff --git a/97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion/accordion_core.js b/97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion/accordion_core.js new file mode 100644 index 0000000..101cb83 --- /dev/null +++ b/97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion/accordion_core.js @@ -0,0 +1,117 @@ +(function( $ ) { + +var setupTeardown = TestHelpers.accordion.setupTeardown, + state = TestHelpers.accordion.state; + +module( "accordion: core", setupTeardown() ); + +$.each( { div: "#list1", ul: "#navigation", dl: "#accordion-dl" }, function( type, selector ) { + test( "markup structure: " + type, function() { + expect( 4 ); + var element = $( selector ).accordion(); + ok( element.hasClass( "ui-accordion" ), "main element is .ui-accordion" ); + equal( element.find( ".ui-accordion-header" ).length, 3, + ".ui-accordion-header elements exist, correct number" ); + equal( element.find( ".ui-accordion-content" ).length, 3, + ".ui-accordion-content elements exist, correct number" ); + deepEqual( element.find( ".ui-accordion-header" ).next().get(), + element.find( ".ui-accordion-content" ).get(), + "content panels come immediately after headers" ); + }); +}); + +test( "handle click on header-descendant", function() { + expect( 1 ); + var element = $( "#navigation" ).accordion(); + $( "#navigation h2:eq(1) a" ).click(); + state( element, 0, 1, 0 ); +}); + +test( "accessibility", function () { + expect( 37 ); + var element = $( "#list1" ).accordion({ + active: 1 + }), + headers = element.find( ".ui-accordion-header" ); + + equal( element.attr( "role" ), "tablist", "element role" ); + headers.each(function( i ) { + var header = headers.eq( i ), + panel = header.next(); + equal( header.attr( "role" ), "tab", "header " + i + " role" ); + equal( header.attr( "aria-controls" ), panel.attr( "id" ), "header " + i + " aria-controls" ); + equal( panel.attr( "role" ), "tabpanel", "panel " + i + " role" ); + equal( panel.attr( "aria-labelledby" ), header.attr( "id" ), "panel " + i + " aria-labelledby" ); + }); + + equal( headers.eq( 1 ).attr( "tabindex" ), 0, "active header has tabindex=0" ); + equal( headers.eq( 1 ).attr( "aria-selected" ), "true", "active tab has aria-selected=true" ); + equal( headers.eq( 1 ).next().attr( "aria-expanded" ), "true", "active tabpanel has aria-expanded=true" ); + equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "false", "active tabpanel has aria-hidden=false" ); + equal( headers.eq( 0 ).attr( "tabindex" ), -1, "inactive header has tabindex=-1" ); + equal( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" ); + equal( headers.eq( 0 ).next().attr( "aria-expanded" ), "false", "inactive tabpanel has aria-expanded=false" ); + equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel has aria-hidden=true" ); + equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header has tabindex=-1" ); + equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" ); + equal( headers.eq( 2 ).next().attr( "aria-expanded" ), "false", "inactive tabpanel has aria-expanded=false" ); + equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel has aria-hidden=true" ); + + element.accordion( "option", "active", 0 ); + equal( headers.eq( 0 ).attr( "tabindex" ), 0, "active header has tabindex=0" ); + equal( headers.eq( 0 ).attr( "aria-selected" ), "true", "active tab has aria-selected=true" ); + equal( headers.eq( 0 ).next().attr( "aria-expanded" ), "true", "active tabpanel has aria-expanded=true" ); + equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "false", "active tabpanel has aria-hidden=false" ); + equal( headers.eq( 1 ).attr( "tabindex" ), -1, "inactive header has tabindex=-1" ); + equal( headers.eq( 1 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" ); + equal( headers.eq( 1 ).next().attr( "aria-expanded" ), "false", "inactive tabpanel has aria-expanded=false" ); + equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel has aria-hidden=true" ); + equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header has tabindex=-1" ); + equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" ); + equal( headers.eq( 2 ).next().attr( "aria-expanded" ), "false", "inactive tabpanel has aria-expanded=false" ); + equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel has aria-hidden=true" ); +}); + +asyncTest( "keyboard support", function() { + expect( 13 ); + var element = $( "#list1" ).accordion(), + headers = element.find( ".ui-accordion-header" ), + anchor = headers.eq( 1 ).next().find( "a" ).eq( 0 ), + keyCode = $.ui.keyCode; + equal( headers.filter( ".ui-state-focus" ).length, 0, "no headers focused on init" ); + headers.eq( 0 ).simulate( "focus" ); + setTimeout(function() { + ok( headers.eq( 0 ).is( ".ui-state-focus" ), "first header has focus" ); + headers.eq( 0 ).simulate( "keydown", { keyCode: keyCode.DOWN } ); + ok( headers.eq( 1 ).is( ".ui-state-focus" ), "DOWN moves focus to next header" ); + headers.eq( 1 ).simulate( "keydown", { keyCode: keyCode.RIGHT } ); + ok( headers.eq( 2 ).is( ".ui-state-focus" ), "RIGHT moves focus to next header" ); + headers.eq( 2 ).simulate( "keydown", { keyCode: keyCode.DOWN } ); + ok( headers.eq( 0 ).is( ".ui-state-focus" ), "DOWN wraps focus to first header" ); + + headers.eq( 0 ).simulate( "keydown", { keyCode: keyCode.UP } ); + ok( headers.eq( 2 ).is( ".ui-state-focus" ), "UP wraps focus to last header" ); + headers.eq( 2 ).simulate( "keydown", { keyCode: keyCode.LEFT } ); + ok( headers.eq( 1 ).is( ".ui-state-focus" ), "LEFT moves focus to previous header" ); + + headers.eq( 1 ).simulate( "keydown", { keyCode: keyCode.HOME } ); + ok( headers.eq( 0 ).is( ".ui-state-focus" ), "HOME moves focus to first header" ); + headers.eq( 0 ).simulate( "keydown", { keyCode: keyCode.END } ); + ok( headers.eq( 2 ).is( ".ui-state-focus" ), "END moves focus to last header" ); + + headers.eq( 2 ).simulate( "keydown", { keyCode: keyCode.ENTER } ); + equal( element.accordion( "option", "active" ) , 2, "ENTER activates panel" ); + headers.eq( 1 ).simulate( "keydown", { keyCode: keyCode.SPACE } ); + equal( element.accordion( "option", "active" ), 1, "SPACE activates panel" ); + + anchor.simulate( "focus" ); + setTimeout(function() { + ok( !headers.eq( 1 ).is( ".ui-state-focus" ), "header loses focus when focusing inside the panel" ); + anchor.simulate( "keydown", { keyCode: keyCode.UP, ctrlKey: true } ); + ok( headers.eq( 1 ).is( ".ui-state-focus" ), "CTRL+UP moves focus to header" ); + start(); + }, 1 ); + }, 1 ); +}); + +}( jQuery ) ); diff --git a/97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion/accordion_events.js b/97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion/accordion_events.js new file mode 100644 index 0000000..79283d1 --- /dev/null +++ b/97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion/accordion_events.js @@ -0,0 +1,169 @@ +(function( $ ) { + +var setupTeardown = TestHelpers.accordion.setupTeardown, + state = TestHelpers.accordion.state; + +module( "accordion: events", setupTeardown() ); + +test( "create", function() { + expect( 15 ); + + var element = $( "#list1" ), + headers = element.children( "h3" ), + contents = headers.next(); + + element.accordion({ + create: function( event, ui ) { + equal( ui.header.length, 1, "header length" ); + strictEqual( ui.header[ 0 ], headers[ 0 ], "header" ); + equal( ui.panel.length, 1, "panel length" ); + strictEqual( ui.panel[ 0 ], contents[ 0 ], "panel" ); + equal( ui.content.length, 1, "content length" ); + strictEqual( ui.content[ 0 ], contents[ 0 ], "content" ); + } + }); + element.accordion( "destroy" ); + + element.accordion({ + active: 2, + create: function( event, ui ) { + equal( ui.header.length, 1, "header length" ); + strictEqual( ui.header[ 0 ], headers[ 2 ], "header" ); + equal( ui.panel.length, 1, "panel length" ); + strictEqual( ui.panel[ 0 ], contents[ 2 ], "panel" ); + equal( ui.content.length, 1, "content length" ); + strictEqual( ui.content[ 0 ], contents[ 2 ], "content" ); + } + }); + element.accordion( "destroy" ); + + element.accordion({ + active: false, + collapsible: true, + create: function( event, ui ) { + equal( ui.header.length, 0, "header length" ); + equal( ui.panel.length, 0, "panel length" ); + equal( ui.content.length, 0, "content length" ); + } + }); + element.accordion( "destroy" ); +}); + +test( "beforeActivate", function() { + expect( 38 ); + var element = $( "#list1" ).accordion({ + active: false, + collapsible: true + }), + headers = element.find( ".ui-accordion-header" ), + content = element.find( ".ui-accordion-content" ); + + element.one( "accordionbeforeactivate", function( event, ui ) { + ok( !( "originalEvent" in event ) ); + equal( ui.oldHeader.length, 0 ); + equal( ui.oldPanel.length, 0 ); + equal( ui.newHeader.length, 1 ); + strictEqual( ui.newHeader[ 0 ], headers[ 0 ] ); + equal( ui.newPanel.length, 1 ); + strictEqual( ui.newPanel[ 0 ], content[ 0 ] ); + state( element, 0, 0, 0 ); + }); + element.accordion( "option", "active", 0 ); + state( element, 1, 0, 0 ); + + element.one( "accordionbeforeactivate", function( event, ui ) { + equal( event.originalEvent.type, "click" ); + equal( ui.oldHeader.length, 1 ); + strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] ); + equal( ui.oldPanel.length, 1 ); + strictEqual( ui.oldPanel[ 0 ], content[ 0 ] ); + equal( ui.newHeader.length, 1 ); + strictEqual( ui.newHeader[ 0 ], headers[ 1 ] ); + equal( ui.newPanel.length, 1 ); + strictEqual( ui.newPanel[ 0 ], content[ 1 ] ); + state( element, 1, 0, 0 ); + }); + headers.eq( 1 ).click(); + state( element, 0, 1, 0 ); + + element.one( "accordionbeforeactivate", function( event, ui ) { + ok( !( "originalEvent" in event ) ); + equal( ui.oldHeader.length, 1 ); + strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] ); + equal( ui.oldPanel.length, 1 ); + strictEqual( ui.oldPanel[ 0 ], content[ 1 ] ); + equal( ui.newHeader.length, 0 ); + equal( ui.newPanel.length, 0 ); + state( element, 0, 1, 0 ); + }); + element.accordion( "option", "active", false ); + state( element, 0, 0, 0 ); + + element.one( "accordionbeforeactivate", function( event, ui ) { + ok( !( "originalEvent" in event ) ); + equal( ui.oldHeader.length, 0 ); + equal( ui.oldPanel.length, 0 ); + equal( ui.newHeader.length, 1 ); + strictEqual( ui.newHeader[ 0 ], headers[ 2 ] ); + equal( ui.newPanel.length, 1 ); + strictEqual( ui.newPanel[ 0 ], content[ 2 ] ); + event.preventDefault(); + state( element, 0, 0, 0 ); + }); + element.accordion( "option", "active", 2 ); + state( element, 0, 0, 0 ); +}); + +test( "activate", function() { + expect( 21 ); + var element = $( "#list1" ).accordion({ + active: false, + collapsible: true + }), + headers = element.find( ".ui-accordion-header" ), + content = element.find( ".ui-accordion-content" ); + + element.one( "accordionactivate", function( event, ui ) { + equal( ui.oldHeader.length, 0 ); + equal( ui.oldPanel.length, 0 ); + equal( ui.newHeader.length, 1 ); + strictEqual( ui.newHeader[ 0 ], headers[ 0 ] ); + equal( ui.newPanel.length, 1 ); + strictEqual( ui.newPanel[ 0 ], content[ 0 ] ); + }); + element.accordion( "option", "active", 0 ); + + element.one( "accordionactivate", function( event, ui ) { + equal( ui.oldHeader.length, 1 ); + strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] ); + equal( ui.oldPanel.length, 1 ); + strictEqual( ui.oldPanel[ 0 ], content[ 0 ] ); + equal( ui.newHeader.length, 1 ); + strictEqual( ui.newHeader[ 0 ], headers[ 1 ] ); + equal( ui.newPanel.length, 1 ); + strictEqual( ui.newPanel[ 0 ], content[ 1 ] ); + }); + headers.eq( 1 ).click(); + + element.one( "accordionactivate", function( event, ui ) { + equal( ui.oldHeader.length, 1 ); + strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] ); + equal( ui.oldPanel.length, 1 ); + strictEqual( ui.oldPanel[ 0 ], content[ 1 ] ); + equal( ui.newHeader.length, 0 ); + equal( ui.newPanel.length, 0 ); + }); + element.accordion( "option", "active", false ); + + // prevent activation + element.one( "accordionbeforeactivate", function( event ) { + ok( true ); + event.preventDefault(); + }); + element.one( "accordionactivate", function() { + ok( false ); + }); + element.accordion( "option", "active", 1 ); +}); + +}( jQuery ) ); diff --git a/97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion/accordion_methods.js b/97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion/accordion_methods.js new file mode 100644 index 0000000..f81bd6d --- /dev/null +++ b/97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion/accordion_methods.js @@ -0,0 +1,126 @@ +(function( $ ) { + +var equalHeight = TestHelpers.accordion.equalHeight, + setupTeardown = TestHelpers.accordion.setupTeardown, + state = TestHelpers.accordion.state; + +module( "accordion: methods", setupTeardown() ); + +test( "destroy", function() { + expect( 1 ); + domEqual( "#list1", function() { + $( "#list1" ).accordion().accordion( "destroy" ); + }); +}); + +test( "enable/disable", function() { + expect( 4 ); + var element = $( "#list1" ).accordion(); + state( element, 1, 0, 0 ); + element.accordion( "disable" ); + // event does nothing + element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" ); + state( element, 1, 0, 0 ); + // option still works + element.accordion( "option", "active", 1 ); + state( element, 0, 1, 0 ); + element.accordion( "enable" ); + element.accordion( "option", "active", 2 ); + state( element, 0, 0, 1 ); +}); + +test( "refresh", function() { + expect( 19 ); + var element = $( "#navigation" ) + .parent() + .height( 300 ) + .end() + .accordion({ + heightStyle: "fill" + }); + equalHeight( element, 255 ); + + element.parent().height( 500 ); + element.accordion( "refresh" ); + equalHeight( element, 455 ); + + element = $( "#list1" ); + element.accordion(); + state( element, 1, 0, 0 ); + + // disable panel via markup + element.find( "h3.bar" ).eq( 1 ).addClass( "ui-state-disabled" ); + element.accordion( "refresh" ); + state( element, 1, 0, 0 ); + + // don't add multiple icons + element.accordion( "refresh" ); + equal( element.find( ".ui-accordion-header-icon" ).length, 3 ); + + // add a panel + element + .append("

    new 1

    ") + .append("
    new 1
    "); + element.accordion( "refresh" ); + state( element, 1, 0, 0, 0 ); + + // remove all tabs + element.find( "h3.bar, div.foo" ).remove(); + element.accordion( "refresh" ); + state( element ); + equal( element.accordion( "option", "active" ), false, "no active accordion panel" ); + + // add panels + element + .append("

    new 2

    ") + .append("
    new 2
    ") + .append("

    new 3

    ") + .append("
    new 3
    ") + .append("

    new 4

    ") + .append("
    new 4
    ") + .append("

    new 5

    ") + .append("
    new 5
    "); + element.accordion( "refresh" ); + state( element, 1, 0, 0, 0 ); + + // activate third tab + element.accordion( "option", "active", 2 ); + state( element, 0, 0, 1, 0 ); + + // remove fourth panel, third panel should stay active + element.find( "h3.bar" ).eq( 3 ).remove(); + element.find( "div.foo" ).eq( 3 ).remove(); + element.accordion( "refresh" ); + state( element, 0, 0, 1 ); + + // remove third (active) panel, second panel should become active + element.find( "h3.bar" ).eq( 2 ).remove(); + element.find( "div.foo" ).eq( 2 ).remove(); + element.accordion( "refresh" ); + state( element, 0, 1 ); + + // remove first panel, previously active panel (now first) should stay active + element.find( "h3.bar" ).eq( 0 ).remove(); + element.find( "div.foo" ).eq( 0 ).remove(); + element.accordion( "refresh" ); + state( element, 1 ); + + // collapse all panels + element.accordion( "option", { + collapsible: true, + active: false + }); + state( element, 0 ); + element.accordion( "refresh" ); + state( element, 0 ); +}); + +test( "widget", function() { + expect( 2 ); + var element = $( "#list1" ).accordion(), + widgetElement = element.accordion( "widget" ); + equal( widgetElement.length, 1, "one element" ); + strictEqual( widgetElement[ 0 ], element[ 0 ], "same element" ); +}); + +}( jQuery ) ); diff --git a/97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion/accordion_options.js b/97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion/accordion_options.js new file mode 100644 index 0000000..214753e --- /dev/null +++ b/97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion/accordion_options.js @@ -0,0 +1,463 @@ +(function( $ ) { + +var equalHeight = TestHelpers.accordion.equalHeight, + setupTeardown = TestHelpers.accordion.setupTeardown, + state = TestHelpers.accordion.state; + +module( "accordion: options", setupTeardown() ); + +test( "{ active: default }", function() { + expect( 2 ); + var element = $( "#list1" ).accordion(); + equal( element.accordion( "option", "active" ), 0 ); + state( element, 1, 0, 0 ); +}); + +test( "{ active: null }", function() { + expect( 2 ); + var element = $( "#list1" ).accordion({ + active: null + }); + equal( element.accordion( "option", "active" ), 0 ); + state( element, 1, 0, 0 ); +}); + +test( "{ active: false }", function() { + expect( 7 ); + var element = $( "#list1" ).accordion({ + active: false, + collapsible: true + }); + state( element, 0, 0, 0 ); + equal( element.find( ".ui-accordion-header.ui-state-active" ).length, 0, "no headers selected" ); + equal( element.accordion( "option", "active" ), false ); + + element.accordion( "option", "collapsible", false ); + state( element, 1, 0, 0 ); + equal( element.accordion( "option", "active" ), 0 ); + + element.accordion( "destroy" ); + element.accordion({ + active: false + }); + state( element, 1, 0, 0 ); + strictEqual( element.accordion( "option", "active" ), 0 ); +}); + +test( "{ active: Number }", function() { + expect( 8 ); + var element = $( "#list1" ).accordion({ + active: 2 + }); + equal( element.accordion( "option", "active" ), 2 ); + state( element, 0, 0, 1 ); + + element.accordion( "option", "active", 0 ); + equal( element.accordion( "option", "active" ), 0 ); + state( element, 1, 0, 0 ); + + element.find( ".ui-accordion-header" ).eq( 1 ).click(); + equal( element.accordion( "option", "active" ), 1 ); + state( element, 0, 1, 0 ); + + element.accordion( "option", "active", 10 ); + equal( element.accordion( "option", "active" ), 1 ); + state( element, 0, 1, 0 ); +}); + +test( "{ active: -Number }", function() { + expect( 8 ); + var element = $( "#list1" ).accordion({ + active: -1 + }); + equal( element.accordion( "option", "active" ), 2 ); + state( element, 0, 0, 1 ); + + element.accordion( "option", "active", -2 ); + equal( element.accordion( "option", "active" ), 1 ); + state( element, 0, 1, 0 ); + + element.accordion( "option", "active", -10 ); + equal( element.accordion( "option", "active" ), 1 ); + state( element, 0, 1, 0 ); + + element.accordion( "option", "active", -3 ); + equal( element.accordion( "option", "active" ), 0 ); + state( element, 1, 0, 0 ); +}); + +test( "{ animate: false }", function() { + expect( 3 ); + var element = $( "#list1" ).accordion({ + animate: false + }), + panels = element.find( ".ui-accordion-content" ), + animate = $.fn.animate; + $.fn.animate = function() { + ok( false, ".animate() called" ); + }; + + ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" ); + element.accordion( "option", "active", 1 ); + ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" ); + ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" ); + $.fn.animate = animate; +}); + +asyncTest( "{ animate: Number }", function() { + expect( 7 ); + var element = $( "#list1" ).accordion({ + animate: 100 + }), + panels = element.find( ".ui-accordion-content" ), + animate = $.fn.animate; + // called twice (both panels) + $.fn.animate = function( props, options ) { + equal( options.duration, 100, "correct duration" ); + equal( options.easing, undefined, "default easing" ); + animate.apply( this, arguments ); + }; + + ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" ); + element.accordion( "option", "active", 1 ); + panels.promise().done(function() { + ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" ); + ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" ); + $.fn.animate = animate; + start(); + }); +}); + +asyncTest( "{ animate: String }", function() { + expect( 7 ); + var element = $( "#list1" ).accordion({ + animate: "linear" + }), + panels = element.find( ".ui-accordion-content" ), + animate = $.fn.animate; + // called twice (both panels) + $.fn.animate = function( props, options ) { + equal( options.duration, undefined, "default duration" ); + equal( options.easing, "linear", "correct easing" ); + animate.apply( this, arguments ); + }; + + ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" ); + element.accordion( "option", "active", 1 ); + panels.promise().done(function() { + ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" ); + ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" ); + $.fn.animate = animate; + start(); + }); +}); + +asyncTest( "{ animate: {} }", function() { + expect( 7 ); + var element = $( "#list1" ).accordion({ + animate: {} + }), + panels = element.find( ".ui-accordion-content" ), + animate = $.fn.animate; + // called twice (both panels) + $.fn.animate = function( props, options ) { + equal( options.duration, undefined, "default duration" ); + equal( options.easing, undefined, "default easing" ); + animate.apply( this, arguments ); + }; + + ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" ); + element.accordion( "option", "active", 1 ); + panels.promise().done(function() { + ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" ); + ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" ); + $.fn.animate = animate; + start(); + }); +}); + +asyncTest( "{ animate: { duration, easing } }", function() { + expect( 7 ); + var element = $( "#list1" ).accordion({ + animate: { duration: 100, easing: "linear" } + }), + panels = element.find( ".ui-accordion-content" ), + animate = $.fn.animate; + // called twice (both panels) + $.fn.animate = function( props, options ) { + equal( options.duration, 100, "correct duration" ); + equal( options.easing, "linear", "correct easing" ); + animate.apply( this, arguments ); + }; + + ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" ); + element.accordion( "option", "active", 1 ); + panels.promise().done(function() { + ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" ); + ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" ); + $.fn.animate = animate; + start(); + }); +}); + +asyncTest( "{ animate: { duration, easing } }, animate down", function() { + expect( 7 ); + var element = $( "#list1" ).accordion({ + active: 1, + animate: { duration: 100, easing: "linear" } + }), + panels = element.find( ".ui-accordion-content" ), + animate = $.fn.animate; + // called twice (both panels) + $.fn.animate = function( props, options ) { + equal( options.duration, 100, "correct duration" ); + equal( options.easing, "linear", "correct easing" ); + animate.apply( this, arguments ); + }; + + ok( panels.eq( 1 ).is( ":visible" ), "first panel visible" ); + element.accordion( "option", "active", 0 ); + panels.promise().done(function() { + ok( panels.eq( 1 ).is( ":hidden" ), "first panel hidden" ); + ok( panels.eq( 0 ).is( ":visible" ), "second panel visible" ); + $.fn.animate = animate; + start(); + }); +}); + +asyncTest( "{ animate: { duration, easing, down } }, animate down", function() { + expect( 7 ); + var element = $( "#list1" ).accordion({ + active: 1, + animate: { + duration: 100, + easing: "linear", + down: { + easing: "swing" + } + } + }), + panels = element.find( ".ui-accordion-content" ), + animate = $.fn.animate; + // called twice (both panels) + $.fn.animate = function( props, options ) { + equal( options.duration, 100, "correct duration" ); + equal( options.easing, "swing", "correct easing" ); + animate.apply( this, arguments ); + }; + + ok( panels.eq( 1 ).is( ":visible" ), "first panel visible" ); + element.accordion( "option", "active", 0 ); + panels.promise().done(function() { + ok( panels.eq( 1 ).is( ":hidden" ), "first panel hidden" ); + ok( panels.eq( 0 ).is( ":visible" ), "second panel visible" ); + $.fn.animate = animate; + start(); + }); +}); + +test( "{ collapsible: false }", function() { + expect( 4 ); + var element = $( "#list1" ).accordion({ + active: 1 + }); + element.accordion( "option", "active", false ); + equal( element.accordion( "option", "active" ), 1 ); + state( element, 0, 1, 0 ); + + element.find( ".ui-accordion-header" ).eq( 1 ).click(); + equal( element.accordion( "option", "active" ), 1 ); + state( element, 0, 1, 0 ); +}); + +test( "{ collapsible: true }", function() { + expect( 6 ); + var element = $( "#list1" ).accordion({ + active: 1, + collapsible: true + }); + + element.accordion( "option", "active", false ); + equal( element.accordion( "option", "active" ), false ); + state( element, 0, 0, 0 ); + + element.accordion( "option", "active", 1 ); + equal( element.accordion( "option", "active" ), 1 ); + state( element, 0, 1, 0 ); + + element.find( ".ui-accordion-header" ).eq( 1 ).click(); + equal( element.accordion( "option", "active" ), false ); + state( element, 0, 0, 0 ); +}); + +test( "{ event: null }", function() { + expect( 5 ); + var element = $( "#list1" ).accordion({ + event: null + }); + state( element, 1, 0, 0 ); + + element.accordion( "option", "active", 1 ); + equal( element.accordion( "option", "active" ), 1 ); + state( element, 0, 1, 0 ); + + // ensure default click handler isn't bound + element.find( ".ui-accordion-header" ).eq( 2 ).click(); + equal( element.accordion( "option", "active" ), 1 ); + state( element, 0, 1, 0 ); +}); + +test( "{ event: custom }", function() { + expect( 11 ); + var element = $( "#list1" ).accordion({ + event: "custom1 custom2" + }); + state( element, 1, 0, 0 ); + + element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom1" ); + equal( element.accordion( "option", "active" ), 1 ); + state( element, 0, 1, 0 ); + + // ensure default click handler isn't bound + element.find( ".ui-accordion-header" ).eq( 2 ).trigger( "click" ); + equal( element.accordion( "option", "active" ), 1 ); + state( element, 0, 1, 0 ); + + element.find( ".ui-accordion-header" ).eq( 2 ).trigger( "custom2" ); + equal( element.accordion( "option", "active" ), 2 ); + state( element, 0, 0, 1 ); + + element.accordion( "option", "event", "custom3" ); + + // ensure old event handlers are unbound + element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom1" ); + element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom2" ); + equal( element.accordion( "option", "active" ), 2 ); + state( element, 0, 0, 1 ); + + element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom3" ); + equal( element.accordion( "option", "active" ), 1 ); + state( element, 0, 1, 0 ); +}); + +test( "{ header: default }", function() { + expect( 2 ); + // default: > li > :first-child,> :not(li):even + // > :not(li):even + state( $( "#list1" ).accordion(), 1, 0, 0); + // > li > :first-child + state( $( "#navigation" ).accordion(), 1, 0, 0); +}); + +test( "{ header: custom }", function() { + expect( 6 ); + var element = $( "#navigationWrapper" ).accordion({ + header: "h2" + }); + element.find( "h2" ).each(function() { + ok( $( this ).hasClass( "ui-accordion-header" ) ); + }); + equal( element.find( ".ui-accordion-header" ).length, 3 ); + state( element, 1, 0, 0 ); + element.accordion( "option", "active", 2 ); + state( element, 0, 0, 1 ); +}); + +test( "{ heightStyle: 'auto' }", function() { + expect( 3 ); + var element = $( "#navigation" ).accordion({ heightStyle: "auto" }); + equalHeight( element, 105 ); +}); + +test( "{ heightStyle: 'content' }", function() { + expect( 3 ); + var element = $( "#navigation" ).accordion({ heightStyle: "content" }), + sizes = element.find( ".ui-accordion-content" ).map(function() { + return $( this ).height(); + }).get(); + equal( sizes[ 0 ], 75 ); + equal( sizes[ 1 ], 105 ); + equal( sizes[ 2 ], 45 ); +}); + +test( "{ heightStyle: 'fill' }", function() { + expect( 3 ); + $( "#navigationWrapper" ).height( 500 ); + var element = $( "#navigation" ).accordion({ heightStyle: "fill" }); + equalHeight( element, 455 ); +}); + +test( "{ heightStyle: 'fill' } with sibling", function() { + expect( 3 ); + $( "#navigationWrapper" ).height( 500 ); + $( "

    Lorem Ipsum

    " ) + .css({ + height: 50, + marginTop: 20, + marginBottom: 30 + }) + .prependTo( "#navigationWrapper" ); + var element = $( "#navigation" ).accordion({ heightStyle: "fill" }); + equalHeight( element , 355 ); +}); + +test( "{ heightStyle: 'fill' } with multiple siblings", function() { + expect( 3 ); + $( "#navigationWrapper" ).height( 500 ); + $( "

    Lorem Ipsum

    " ) + .css({ + height: 50, + marginTop: 20, + marginBottom: 30 + }) + .prependTo( "#navigationWrapper" ); + $( "

    Lorem Ipsum

    " ) + .css({ + height: 50, + marginTop: 20, + marginBottom: 30, + position: "absolute" + }) + .prependTo( "#navigationWrapper" ); + $( "

    Lorem Ipsum

    " ) + .css({ + height: 25, + marginTop: 10, + marginBottom: 15 + }) + .prependTo( "#navigationWrapper" ); + var element = $( "#navigation" ).accordion({ heightStyle: "fill" }); + equalHeight( element, 305 ); +}); + +test( "{ icons: false }", function() { + expect( 8 ); + var element = $( "#list1" ); + function icons( on ) { + deepEqual( element.find( "span.ui-icon").length, on ? 3 : 0 ); + deepEqual( element.find( ".ui-accordion-header.ui-accordion-icons" ).length, on ? 3 : 0 ); + } + element.accordion(); + icons( true ); + element.accordion( "destroy" ).accordion({ + icons: false + }); + icons( false ); + element.accordion( "option", "icons", { header: "foo", activeHeader: "bar" } ); + icons( true ); + element.accordion( "option", "icons", false ); + icons( false ); +}); + +test( "{ icons: hash }", function() { + expect( 3 ); + var element = $( "#list1" ).accordion({ + icons: { activeHeader: "a1", header: "h1" } + }); + ok( element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ).hasClass( "a1" ) ); + element.accordion( "option", "icons", { activeHeader: "a2", header: "h2" } ); + ok( !element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ).hasClass( "a1" ) ); + ok( element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ).hasClass( "a2" ) ); +}); + +}( jQuery ) ); diff --git a/97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion/accordion_test_helpers.js b/97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion/accordion_test_helpers.js new file mode 100644 index 0000000..643f8e2 --- /dev/null +++ b/97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion/accordion_test_helpers.js @@ -0,0 +1,27 @@ +TestHelpers.accordion = { + equalHeight: function( accordion, height ) { + accordion.find( ".ui-accordion-content" ).each(function() { + equal( $( this ).outerHeight(), height ); + }); + }, + + setupTeardown: function() { + var animate = $.ui.accordion.prototype.options.animate; + return { + setup: function() { + $.ui.accordion.prototype.options.animate = false; + }, + teardown: function() { + $.ui.accordion.prototype.options.animate = animate; + } + }; + }, + + state: function( accordion ) { + var expected = $.makeArray( arguments ).slice( 1 ), + actual = accordion.find( ".ui-accordion-content" ).map(function() { + return $( this ).css( "display" ) === "none" ? 0 : 1; + }).get(); + QUnit.push( QUnit.equiv(actual, expected), actual, expected ); + } +}; diff --git a/97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion/all.html b/97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion/all.html new file mode 100644 index 0000000..0fe5bf1 --- /dev/null +++ b/97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/accordion/all.html @@ -0,0 +1,30 @@ + + + + + jQuery UI Accordion Test Suite + + + + + + + + + + + + + +

    jQuery UI Accordion Test Suite

    +

    +
    +

    +
      +
      + +
      + + -- cgit v1.2.2