Index: trunk/phase3/tests/qunit/index.html |
— | — | @@ -85,16 +85,7 @@ |
86 | 86 | <h2 id="qunit-userAgent"></h2> |
87 | 87 | <ol id="qunit-tests"></ol> |
88 | 88 | |
89 | | -<!-- Rough page structure for scripts needing it (Vector based). --> |
90 | 89 | <!-- Scripts inserting stuff here shall remove it themselfs! --> |
91 | | -<div id="mw-content"> |
92 | | - <div id="bodyContent"></div> |
93 | | - <div id="mw-panel"> |
94 | | - <div id="p-tb" class="portal"> |
95 | | - <ul class="body"> |
96 | | - </ul> |
97 | | - </div> |
98 | | - </div> |
99 | | -</div> |
| 90 | +<div id="content"></div> |
100 | 91 | </body> |
101 | 92 | </html> |
Index: trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.util.js |
— | — | @@ -49,15 +49,18 @@ |
50 | 50 | test( 'addCSS', function() { |
51 | 51 | expect(3); |
52 | 52 | |
53 | | - var a = mw.util.addCSS( '#bodyContent { visibility: hidden; }' ); |
54 | | - equal( typeof a, 'object', 'addCSS returned an object' ); |
55 | | - strictEqual( a.disabled, false, 'property "disabled" is available and set to false' ); |
| 53 | + var $testEl = $( '<div>' ).attr( 'id', 'mw-addcsstest' ).appendTo( 'body' ); |
56 | 54 | |
57 | | - var $b = $('#bodyContent'); |
58 | | - equal( $b.css('visibility'), 'hidden', 'Added style properties are in effect' ); |
| 55 | + var style = mw.util.addCSS( '#mw-addcsstest { visibility: hidden; }' ); |
| 56 | + equal( typeof style, 'object', 'addCSS returned an object' ); |
| 57 | + strictEqual( style.disabled, false, 'property "disabled" is available and set to false' ); |
59 | 58 | |
| 59 | + equal( $testEl.css('visibility'), 'hidden', 'Added style properties are in effect' ); |
| 60 | + |
60 | 61 | // Clean up |
61 | | - $( a.ownerNode ).remove(); |
| 62 | + $( style.ownerNode ) |
| 63 | + .add( $testEl ) |
| 64 | + .remove(); |
62 | 65 | }); |
63 | 66 | |
64 | 67 | test( 'toggleToc', function() { |
— | — | @@ -123,8 +126,21 @@ |
124 | 127 | test( 'addPortletLink', function() { |
125 | 128 | expect(5); |
126 | 129 | |
| 130 | + var mwPanel = '<div id="mw-panel" class="noprint">\ |
| 131 | + <h5>Toolbox</h5>\ |
| 132 | + <div class="portlet" id="p-tb">\ |
| 133 | + <ul class="body"></ul>\ |
| 134 | + </div>\ |
| 135 | +</div>', |
| 136 | + vectorTabs = '<div id="p-views" class="vectorTabs">\ |
| 137 | + <h5>Views</h5>\ |
| 138 | + <ul></ul>\ |
| 139 | +</div>', |
| 140 | + $mwPanel = $(mwPanel).appendTo( 'body' ), |
| 141 | + $vectorTabs = $(vectorTabs).appendTo( 'body' ); |
| 142 | + |
127 | 143 | var A = mw.util.addPortletLink( 'p-tb', 'http://mediawiki.org/wiki/ResourceLoader', |
128 | | - 'ResourceLoader', 't-rl', 'More info about ResourceLoader on MediaWiki.org ', 'l', '#t-specialpages' ); |
| 144 | + 'ResourceLoader', 't-rl', 'More info about ResourceLoader on MediaWiki.org ', 'l' ); |
129 | 145 | |
130 | 146 | ok( $.isDomElement( A ), 'addPortletLink returns a valid DOM Element according to $.isDomElement' ); |
131 | 147 | |
— | — | @@ -132,7 +148,7 @@ |
133 | 149 | "MediaWiki.org", "t-mworg", "Go to MediaWiki.org ", "m", A ); |
134 | 150 | |
135 | 151 | equal( $( B ).attr( 'id' ), 't-mworg', 'Link has correct ID set' ); |
136 | | - equal( $( B ).closest( '.portal' ).attr( 'id' ), 'p-tb', 'Link was inserted within correct portlet' ); |
| 152 | + equal( $( B ).closest( '.portlet' ).attr( 'id' ), 'p-tb', 'Link was inserted within correct portlet' ); |
137 | 153 | equal( $( B ).next().attr( 'id' ), 't-rl', 'Link is in the correct position (by passing nextnode)' ); |
138 | 154 | |
139 | 155 | var C = mw.util.addPortletLink( "p-tb", "http://mediawiki.org/wiki/RL/DM", |
— | — | @@ -141,7 +157,10 @@ |
142 | 158 | equal( $( C ).next().attr( 'id' ), 't-rl', 'Link is in the correct position (by passing CSS selector)' ); |
143 | 159 | |
144 | 160 | // Clean up |
145 | | - $( [A, B, C] ).remove(); |
| 161 | + $( [A, B, C] ) |
| 162 | + .add( $mwPanel ) |
| 163 | + .add( $vectorTabs ) |
| 164 | + .remove(); |
146 | 165 | }); |
147 | 166 | |
148 | 167 | test( 'jsMessage', function() { |