installer: Avoid <doclink/> hack for 'config-sidebar' rendering
[lhc/web/wiklou.git] / tests / qunit / suites / resources / mediawiki.special / mediawiki.special.recentchanges.test.js
1 ( function () {
2 QUnit.module( 'mediawiki.special.recentchanges', QUnit.newMwEnvironment() );
3
4 // TODO: verify checkboxes == [ 'nsassociated', 'nsinvert' ]
5
6 QUnit.test( '"all" namespace hides checkboxes', function ( assert ) {
7 var selectHtml, $env, $options,
8 rc = require( 'mediawiki.special.recentchanges' );
9
10 // from Special:Recentchanges
11 selectHtml = '<select id="namespace" name="namespace" class="namespaceselector">'
12 + '<option value="" selected="selected">all</option>'
13 + '<option value="0">(Main)</option>'
14 + '<option value="1">Talk</option>'
15 + '<option value="2">User</option>'
16 + '<option value="3">User talk</option>'
17 + '<option value="4">ProjectName</option>'
18 + '<option value="5">ProjectName talk</option>'
19 + '</select>'
20 + '<span class="mw-input-with-label mw-input-hidden">'
21 + '<input name="invert" type="checkbox" value="1" id="nsinvert" title="no title" />'
22 + '<label for="nsinvert" title="no title">Invert selection</label>'
23 + '</span>'
24 + '<span class="mw-input-with-label mw-input-hidden">'
25 + '<input name="associated" type="checkbox" value="1" id="nsassociated" title="no title" />'
26 + '<label for="nsassociated" title="no title">Associated namespace</label>'
27 + '</span>'
28 + '<input type="submit" value="Go" />'
29 + '<input type="hidden" value="Special:RecentChanges" name="title" />';
30
31 $env = $( '<div>' ).html( selectHtml ).appendTo( 'body' );
32
33 // TODO abstract the double strictEquals
34
35 // At first checkboxes are hidden
36 assert.strictEqual( $( '#nsinvert' ).closest( '.mw-input-with-label' ).hasClass( 'mw-input-hidden' ), true );
37 assert.strictEqual( $( '#nsassociated' ).closest( '.mw-input-with-label' ).hasClass( 'mw-input-hidden' ), true );
38
39 // Initiate the recentchanges module
40 rc.init();
41
42 // By default
43 assert.strictEqual( $( '#nsinvert' ).closest( '.mw-input-with-label' ).hasClass( 'mw-input-hidden' ), true );
44 assert.strictEqual( $( '#nsassociated' ).closest( '.mw-input-with-label' ).hasClass( 'mw-input-hidden' ), true );
45
46 // select second option...
47 $options = $( '#namespace' ).find( 'option' );
48 $options.eq( 0 ).removeProp( 'selected' );
49 $options.eq( 1 ).prop( 'selected', true );
50 $( '#namespace' ).trigger( 'change' );
51
52 // ... and checkboxes should be visible again
53 assert.strictEqual( $( '#nsinvert' ).closest( '.mw-input-with-label' ).hasClass( 'mw-input-hidden' ), false );
54 assert.strictEqual( $( '#nsassociated' ).closest( '.mw-input-with-label' ).hasClass( 'mw-input-hidden' ), false );
55
56 // select first option ( 'all' namespace)...
57 $options.eq( 1 ).removeProp( 'selected' );
58 $options.eq( 0 ).prop( 'selected', true );
59 $( '#namespace' ).trigger( 'change' );
60
61 // ... and checkboxes should now be hidden
62 assert.strictEqual( $( '#nsinvert' ).closest( '.mw-input-with-label' ).hasClass( 'mw-input-hidden' ), true );
63 assert.strictEqual( $( '#nsassociated' ).closest( '.mw-input-with-label' ).hasClass( 'mw-input-hidden' ), true );
64
65 // DOM cleanup
66 $env.remove();
67 } );
68 }() );