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,
8 rc = require( 'mediawiki.special.recentchanges' );
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>'
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" />';
27 $env = $( '<div>' ).html( selectHtml ).appendTo( 'body' );
29 // TODO abstract the double strictEquals
31 // At first checkboxes are enabled
32 assert.strictEqual( $( '#nsinvert' ).prop( 'disabled' ), false );
33 assert.strictEqual( $( '#nsassociated' ).prop( 'disabled' ), false );
35 // Initiate the recentchanges module
39 assert.strictEqual( $( '#nsinvert' ).prop( 'disabled' ), true );
40 assert.strictEqual( $( '#nsassociated' ).prop( 'disabled' ), true );
42 // select second option...
43 $options = $( '#namespace' ).find( 'option' );
44 $options.eq( 0 ).removeProp( 'selected' );
45 $options.eq( 1 ).prop( 'selected', true );
46 $( '#namespace' ).change();
48 // ... and checkboxes should be enabled again
49 assert.strictEqual( $( '#nsinvert' ).prop( 'disabled' ), false );
50 assert.strictEqual( $( '#nsassociated' ).prop( 'disabled' ), false );
52 // select first option ( 'all' namespace)...
53 $options.eq( 1 ).removeProp( 'selected' );
54 $options.eq( 0 ).prop( 'selected', true );
55 $( '#namespace' ).change();
57 // ... and checkboxes should now be disabled
58 assert.strictEqual( $( '#nsinvert' ).prop( 'disabled' ), true );
59 assert.strictEqual( $( '#nsassociated' ).prop( 'disabled' ), true );
64 }( mediaWiki, jQuery ) );