1 module( 'mediawiki.special.recentchanges', QUnit.newMwEnvironment() );
3 test( '-- Initial check', function() {
5 ok( mw.special.recentchanges.init, 'mw.special.recentchanges.init defined' );
6 ok( mw.special.recentchanges.updateCheckboxes, 'mw.special.recentchanges.updateCheckboxes defined' );
7 // TODO: verify checkboxes == [ 'nsassociated', 'nsinvert' ]
10 test( '"all" namespace disable checkboxes', function() {
12 // from Special:Recentchanges
14 '<select id="namespace" name="namespace" class="namespaceselector">'
15 + '<option value="" selected="selected">all</option>'
16 + '<option value="0">(Main)</option>'
17 + '<option value="1">Talk</option>'
18 + '<option value="2">User</option>'
19 + '<option value="3">User talk</option>'
20 + '<option value="4">ProjectName</option>'
21 + '<option value="5">ProjectName talk</option>'
23 + '<input name="invert" type="checkbox" value="1" id="nsinvert" title="no title" />'
24 + '<label for="nsinvert" title="no title">Invert selection</label>'
25 + '<input name="associated" type="checkbox" value="1" id="nsassociated" title="no title" />'
26 + '<label for="nsassociated" title="no title">Associated namespace</label>'
27 + '<input type="submit" value="Go" />'
28 + '<input type="hidden" value="Special:RecentChanges" name="title" />'
31 var $env = $( '<div>' ).html( select ).appendTo( 'body' );
33 // TODO abstract the double strictEquals
35 // At first checkboxes are enabled
36 strictEqual( $( '#nsinvert' ).prop( 'disabled' ), false );
37 strictEqual( $( '#nsassociated' ).prop( 'disabled' ), false );
39 // Initiate the recentchanges module
40 mw.special.recentchanges.init();
43 strictEqual( $( '#nsinvert' ).prop( 'disabled' ), true );
44 strictEqual( $( '#nsassociated' ).prop( 'disabled' ), true );
46 // select second option...
47 var $options = $( '#namespace' ).find( 'option' );
48 $options.eq(0).removeProp( 'selected' );
49 $options.eq(1).prop( 'selected', true );
50 $( '#namespace' ).change();
52 // ... and checkboxes should be enabled again
53 strictEqual( $( '#nsinvert' ).prop( 'disabled' ), false );
54 strictEqual( $( '#nsassociated' ).prop( 'disabled' ), false );
56 // select first option ( 'all' namespace)...
57 $options.eq(1).removeProp( 'selected' );
58 $options.eq(0).prop( 'selected', true );
59 $( '#namespace' ).change();
61 // ... and checkboxes should now be disabled
62 strictEqual( $( '#nsinvert' ).prop( 'disabled' ), true );
63 strictEqual( $( '#nsassociated' ).prop( 'disabled' ), true );