Merge "[FileBackend] Added getScopedLocksForOps() function."
[lhc/web/wiklou.git] / tests / qunit / suites / resources / mediawiki.special / mediawiki.special.recentchanges.test.js
1 module( 'mediawiki.special.recentchanges', QUnit.newMwEnvironment() );
2
3 test( '-- Initial check', function() {
4 expect( 2 );
5 ok( mw.special.recentchanges.init, 'mw.special.recentchanges.init defined' );
6 ok( mw.special.recentchanges.updateCheckboxes, 'mw.special.recentchanges.updateCheckboxes defined' );
7 // TODO: verify checkboxes == [ 'nsassociated', 'nsinvert' ]
8 });
9
10 test( '"all" namespace disable checkboxes', function() {
11
12 // from Special:Recentchanges
13 var select =
14 '<select id="namespace" name="namespace" class="namespaceselector">'
15 + '<option value="" selected="selected">all</option>'
16 + '<option value="0">(Main)</option>'
17 + '<option value="1">Talk</option>'
18 + '<option value="2">User</option>'
19 + '<option value="3">User talk</option>'
20 + '<option value="4">ProjectName</option>'
21 + '<option value="5">ProjectName talk</option>'
22 + '</select>'
23 + '<input name="invert" type="checkbox" value="1" id="nsinvert" title="no title" />'
24 + '<label for="nsinvert" title="no title">Invert selection</label>'
25 + '<input name="associated" type="checkbox" value="1" id="nsassociated" title="no title" />'
26 + '<label for="nsassociated" title="no title">Associated namespace</label>'
27 + '<input type="submit" value="Go" />'
28 + '<input type="hidden" value="Special:RecentChanges" name="title" />'
29 ;
30
31 var $env = $( '<div>' ).html( select ).appendTo( 'body' );
32
33 // TODO abstract the double strictEquals
34
35 // At first checkboxes are enabled
36 strictEqual( $( '#nsinvert' ).prop( 'disabled' ), false );
37 strictEqual( $( '#nsassociated' ).prop( 'disabled' ), false );
38
39 // Initiate the recentchanges module
40 mw.special.recentchanges.init();
41
42 // By default
43 strictEqual( $( '#nsinvert' ).prop( 'disabled' ), true );
44 strictEqual( $( '#nsassociated' ).prop( 'disabled' ), true );
45
46 // select second option...
47 var $options = $( '#namespace' ).find( 'option' );
48 $options.eq(0).removeProp( 'selected' );
49 $options.eq(1).prop( 'selected', true );
50 $( '#namespace' ).change();
51
52 // ... and checkboxes should be enabled again
53 strictEqual( $( '#nsinvert' ).prop( 'disabled' ), false );
54 strictEqual( $( '#nsassociated' ).prop( 'disabled' ), false );
55
56 // select first option ( 'all' namespace)...
57 $options.eq(1).removeProp( 'selected' );
58 $options.eq(0).prop( 'selected', true );
59 $( '#namespace' ).change();
60
61 // ... and checkboxes should now be disabled
62 strictEqual( $( '#nsinvert' ).prop( 'disabled' ), true );
63 strictEqual( $( '#nsassociated' ).prop( 'disabled' ), true );
64
65 // DOM cleanup
66 $env.remove();
67 });