From 2b709048f4164a9c289277746e5df600f91b7999 Mon Sep 17 00:00:00 2001 From: Krinkle Date: Fri, 24 Jun 2011 19:35:21 +0000 Subject: [PATCH] Removing fake html structure from qunit/index.html, instead putting needed nodes in the test suite. Leaving #content due to onload dependancies. This will all be redundant as soon as phase 2 for JS Unit testing is complete (at which point it will be on an actual wiki page) --- tests/qunit/index.html | 11 +----- .../resources/mediawiki/mediawiki.util.js | 37 ++++++++++++++----- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/tests/qunit/index.html b/tests/qunit/index.html index 0e1a0450c7..828fc0836a 100644 --- a/tests/qunit/index.html +++ b/tests/qunit/index.html @@ -85,16 +85,7 @@

    - -
    -
    -
    -
    -
      -
    -
    -
    -
    +
    diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.util.js b/tests/qunit/suites/resources/mediawiki/mediawiki.util.js index 566142278d..9b06b35f78 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.util.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.util.js @@ -49,15 +49,18 @@ test( 'wikiScript', function() { test( 'addCSS', function() { expect(3); - var a = mw.util.addCSS( '#bodyContent { visibility: hidden; }' ); - equal( typeof a, 'object', 'addCSS returned an object' ); - strictEqual( a.disabled, false, 'property "disabled" is available and set to false' ); + var $testEl = $( '
    ' ).attr( 'id', 'mw-addcsstest' ).appendTo( 'body' ); - var $b = $('#bodyContent'); - equal( $b.css('visibility'), 'hidden', 'Added style properties are in effect' ); + var style = mw.util.addCSS( '#mw-addcsstest { visibility: hidden; }' ); + equal( typeof style, 'object', 'addCSS returned an object' ); + strictEqual( style.disabled, false, 'property "disabled" is available and set to false' ); + + equal( $testEl.css('visibility'), 'hidden', 'Added style properties are in effect' ); // Clean up - $( a.ownerNode ).remove(); + $( style.ownerNode ) + .add( $testEl ) + .remove(); }); test( 'toggleToc', function() { @@ -123,8 +126,21 @@ test( '$content', function() { test( 'addPortletLink', function() { expect(5); + var mwPanel = '
    \ +
    Toolbox
    \ +
    \ +
      \ +
      \ +
      ', + vectorTabs = '
      \ +
      Views
      \ +
        \ +
        ', + $mwPanel = $(mwPanel).appendTo( 'body' ), + $vectorTabs = $(vectorTabs).appendTo( 'body' ); + var A = mw.util.addPortletLink( 'p-tb', 'http://mediawiki.org/wiki/ResourceLoader', - 'ResourceLoader', 't-rl', 'More info about ResourceLoader on MediaWiki.org ', 'l', '#t-specialpages' ); + 'ResourceLoader', 't-rl', 'More info about ResourceLoader on MediaWiki.org ', 'l' ); ok( $.isDomElement( A ), 'addPortletLink returns a valid DOM Element according to $.isDomElement' ); @@ -132,7 +148,7 @@ test( 'addPortletLink', function() { "MediaWiki.org", "t-mworg", "Go to MediaWiki.org ", "m", A ); equal( $( B ).attr( 'id' ), 't-mworg', 'Link has correct ID set' ); - equal( $( B ).closest( '.portal' ).attr( 'id' ), 'p-tb', 'Link was inserted within correct portlet' ); + equal( $( B ).closest( '.portlet' ).attr( 'id' ), 'p-tb', 'Link was inserted within correct portlet' ); equal( $( B ).next().attr( 'id' ), 't-rl', 'Link is in the correct position (by passing nextnode)' ); var C = mw.util.addPortletLink( "p-tb", "http://mediawiki.org/wiki/RL/DM", @@ -141,7 +157,10 @@ test( 'addPortletLink', function() { equal( $( C ).next().attr( 'id' ), 't-rl', 'Link is in the correct position (by passing CSS selector)' ); // Clean up - $( [A, B, C] ).remove(); + $( [A, B, C] ) + .add( $mwPanel ) + .add( $vectorTabs ) + .remove(); }); test( 'jsMessage', function() { -- 2.20.1