2 QUnit.module( 'mediawiki.special.recentchanges', QUnit.newMwEnvironment() );
4 // TODO: verify checkboxes == [ 'nsassociated', 'nsinvert' ]
6 QUnit.test( '"all" namespace disable checkboxes', 8, function ( assert ) {
7 var selectHtml, $env, $options;
9 // from Special:Recentchanges
10 selectHtml = '<select id="namespace" name="namespace" class="namespaceselector">'
11 + '<option value="" selected="selected">all</option>'
12 + '<option value="0">(Main)</option>'
13 + '<option value="1">Talk</option>'
14 + '<option value="2">User</option>'
15 + '<option value="3">User talk</option>'
16 + '<option value="4">ProjectName</option>'
17 + '<option value="5">ProjectName talk</option>'
19 + '<input name="invert" type="checkbox" value="1" id="nsinvert" title="no title" />'
20 + '<label for="nsinvert" title="no title">Invert selection</label>'
21 + '<input name="associated" type="checkbox" value="1" id="nsassociated" title="no title" />'
22 + '<label for="nsassociated" title="no title">Associated namespace</label>'
23 + '<input type="submit" value="Go" />'
24 + '<input type="hidden" value="Special:RecentChanges" name="title" />';
26 $env = $( '<div>' ).html( selectHtml ).appendTo( 'body' );
28 // TODO abstract the double strictEquals
30 // At first checkboxes are enabled
31 assert.strictEqual( $( '#nsinvert' ).prop( 'disabled' ), false );
32 assert.strictEqual( $( '#nsassociated' ).prop( 'disabled' ), false );
34 // Initiate the recentchanges module
35 mw.special.recentchanges.init();
38 assert.strictEqual( $( '#nsinvert' ).prop( 'disabled' ), true );
39 assert.strictEqual( $( '#nsassociated' ).prop( 'disabled' ), true );
41 // select second option...
42 $options = $( '#namespace' ).find( 'option' );
43 $options.eq( 0 ).removeProp( 'selected' );
44 $options.eq( 1 ).prop( 'selected', true );
45 $( '#namespace' ).change();
47 // ... and checkboxes should be enabled again
48 assert.strictEqual( $( '#nsinvert' ).prop( 'disabled' ), false );
49 assert.strictEqual( $( '#nsassociated' ).prop( 'disabled' ), false );
51 // select first option ( 'all' namespace)...
52 $options.eq( 1 ).removeProp( 'selected' );
53 $options.eq( 0 ).prop( 'selected', true );
54 $( '#namespace' ).change();
56 // ... and checkboxes should now be disabled
57 assert.strictEqual( $( '#nsinvert' ).prop( 'disabled' ), true );
58 assert.strictEqual( $( '#nsassociated' ).prop( 'disabled' ), true );
63 }( mediaWiki, jQuery ) );