(bug 37755) Set robot meta tags for 'view source' pages
[lhc/web/wiklou.git] / tests / qunit / suites / resources / mediawiki.special / mediawiki.special.recentchanges.test.js
1 QUnit.module( 'mediawiki.special.recentchanges', QUnit.newMwEnvironment() );
2
3 // TODO: verify checkboxes == [ 'nsassociated', 'nsinvert' ]
4
5 QUnit.test( '"all" namespace disable checkboxes', function ( assert ) {
6
7 // from Special:Recentchanges
8 var select =
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>'
17 + '</select>'
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" />'
24 ;
25
26 var $env = $( '<div>' ).html( select ).appendTo( 'body' );
27
28 // TODO abstract the double strictEquals
29
30 // At first checkboxes are enabled
31 assert.strictEqual( $( '#nsinvert' ).prop( 'disabled' ), false );
32 assert.strictEqual( $( '#nsassociated' ).prop( 'disabled' ), false );
33
34 // Initiate the recentchanges module
35 mw.special.recentchanges.init();
36
37 // By default
38 assert.strictEqual( $( '#nsinvert' ).prop( 'disabled' ), true );
39 assert.strictEqual( $( '#nsassociated' ).prop( 'disabled' ), true );
40
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();
46
47 // ... and checkboxes should be enabled again
48 assert.strictEqual( $( '#nsinvert' ).prop( 'disabled' ), false );
49 assert.strictEqual( $( '#nsassociated' ).prop( 'disabled' ), false );
50
51 // select first option ( 'all' namespace)...
52 $options.eq(1).removeProp( 'selected' );
53 $options.eq(0).prop( 'selected', true );
54 $( '#namespace' ).change();
55
56 // ... and checkboxes should now be disabled
57 assert.strictEqual( $( '#nsinvert' ).prop( 'disabled' ), true );
58 assert.strictEqual( $( '#nsassociated' ).prop( 'disabled' ), true );
59
60 // DOM cleanup
61 $env.remove();
62 });