1 QUnit
.module( 'mediawiki.special.recentchanges', QUnit
.newMwEnvironment() );
3 // TODO: verify checkboxes == [ 'nsassociated', 'nsinvert' ]
5 QUnit
.test( '"all" namespace disable checkboxes', function ( assert
) {
7 // from Special:Recentchanges
9 '<select id="namespace" name="namespace" class="namespaceselector">'
10 + '<option value="" selected="selected">all</option>'
11 + '<option value="0">(Main)</option>'
12 + '<option value="1">Talk</option>'
13 + '<option value="2">User</option>'
14 + '<option value="3">User talk</option>'
15 + '<option value="4">ProjectName</option>'
16 + '<option value="5">ProjectName talk</option>'
18 + '<input name="invert" type="checkbox" value="1" id="nsinvert" title="no title" />'
19 + '<label for="nsinvert" title="no title">Invert selection</label>'
20 + '<input name="associated" type="checkbox" value="1" id="nsassociated" title="no title" />'
21 + '<label for="nsassociated" title="no title">Associated namespace</label>'
22 + '<input type="submit" value="Go" />'
23 + '<input type="hidden" value="Special:RecentChanges" name="title" />'
26 var $env
= $( '<div>' ).html( select
).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 var $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 );