Merge "Improve "selfmove" message's wording"
[lhc/web/wiklou.git] / tests / qunit / suites / resources / mediawiki.special / mediawiki.special.recentchanges.test.js
1 ( function ( $ ) {
2 QUnit.module( 'mediawiki.special.recentchanges', QUnit.newMwEnvironment() );
3
4 // TODO: verify checkboxes == [ 'nsassociated', 'nsinvert' ]
5
6 QUnit.test( '"all" namespace disable checkboxes', function ( assert ) {
7 var selectHtml, $env, $options,
8 rc = require( 'mediawiki.special.recentchanges' );
9
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>'
19 + '</select>'
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" />';
26
27 $env = $( '<div>' ).html( selectHtml ).appendTo( 'body' );
28
29 // TODO abstract the double strictEquals
30
31 // At first checkboxes are enabled
32 assert.strictEqual( $( '#nsinvert' ).prop( 'disabled' ), false );
33 assert.strictEqual( $( '#nsassociated' ).prop( 'disabled' ), false );
34
35 // Initiate the recentchanges module
36 rc.init();
37
38 // By default
39 assert.strictEqual( $( '#nsinvert' ).prop( 'disabled' ), true );
40 assert.strictEqual( $( '#nsassociated' ).prop( 'disabled' ), true );
41
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();
47
48 // ... and checkboxes should be enabled again
49 assert.strictEqual( $( '#nsinvert' ).prop( 'disabled' ), false );
50 assert.strictEqual( $( '#nsassociated' ).prop( 'disabled' ), false );
51
52 // select first option ( 'all' namespace)...
53 $options.eq( 1 ).removeProp( 'selected' );
54 $options.eq( 0 ).prop( 'selected', true );
55 $( '#namespace' ).change();
56
57 // ... and checkboxes should now be disabled
58 assert.strictEqual( $( '#nsinvert' ).prop( 'disabled' ), true );
59 assert.strictEqual( $( '#nsassociated' ).prop( 'disabled' ), true );
60
61 // DOM cleanup
62 $env.remove();
63 } );
64 }( jQuery ) );