2 QUnit
.module( 'mediawiki.special.recentchanges', QUnit
.newMwEnvironment() );
4 // TODO: verify checkboxes == [ 'nsassociated', 'nsinvert' ]
6 QUnit
.test( '"all" namespace disable checkboxes', function ( assert
) {
7 var selectHtml
, $env
, $options
;
9 // from Special:Recentchanges
11 '<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>'
20 + '<input name="invert" type="checkbox" value="1" id="nsinvert" title="no title" />'
21 + '<label for="nsinvert" title="no title">Invert selection</label>'
22 + '<input name="associated" type="checkbox" value="1" id="nsassociated" title="no title" />'
23 + '<label for="nsassociated" title="no title">Associated namespace</label>'
24 + '<input type="submit" value="Go" />'
25 + '<input type="hidden" value="Special:RecentChanges" name="title" />'
28 $env
= $( '<div>' ).html( selectHtml
).appendTo( 'body' );
30 // TODO abstract the double strictEquals
32 // At first checkboxes are enabled
33 assert
.strictEqual( $( '#nsinvert' ).prop( 'disabled' ), false );
34 assert
.strictEqual( $( '#nsassociated' ).prop( 'disabled' ), false );
36 // Initiate the recentchanges module
37 mw
.special
.recentchanges
.init();
40 assert
.strictEqual( $( '#nsinvert' ).prop( 'disabled' ), true );
41 assert
.strictEqual( $( '#nsassociated' ).prop( 'disabled' ), true );
43 // select second option...
44 $options
= $( '#namespace' ).find( 'option' );
45 $options
.eq(0).removeProp( 'selected' );
46 $options
.eq(1).prop( 'selected', true );
47 $( '#namespace' ).change();
49 // ... and checkboxes should be enabled again
50 assert
.strictEqual( $( '#nsinvert' ).prop( 'disabled' ), false );
51 assert
.strictEqual( $( '#nsassociated' ).prop( 'disabled' ), false );
53 // select first option ( 'all' namespace)...
54 $options
.eq(1).removeProp( 'selected' );
55 $options
.eq(0).prop( 'selected', true );
56 $( '#namespace' ).change();
58 // ... and checkboxes should now be disabled
59 assert
.strictEqual( $( '#nsinvert' ).prop( 'disabled' ), true );
60 assert
.strictEqual( $( '#nsassociated' ).prop( 'disabled' ), true );
65 }( mediaWiki
, jQuery
) );