fca2a80b11ace1dcc9552ebbbcc26e48a0476431
1 module( 'mediawiki.special.recentchanges' );
3 test( '-- Initial check', function() {
5 ok( mw
.special
.recentchanges
.init
,
6 'mw.special.recentchanges.init defined'
8 ok( mw
.special
.recentchanges
.updateCheckboxes
,
9 'mw.special.recentchanges.updateCheckboxes defined'
11 // TODO: verify checkboxes == [ 'nsassociated', 'nsinvert' ]
14 test( '"all" namespace disable checkboxes', function() {
16 // from Special:Recentchanges
18 '<select id="namespace" name="namespace" class="namespaceselector">'
19 + '<option value="" selected="selected">all</option>'
20 + '<option value="0">(Main)</option>'
21 + '<option value="1">Talk</option>'
22 + '<option value="2">User</option>'
23 + '<option value="3">User talk</option>'
24 + '<option value="4">ProjectName</option>'
25 + '<option value="5">ProjectName talk</option>'
27 + '<input name="invert" type="checkbox" value="1" id="nsinvert" title="no title" />'
28 + '<label for="nsinvert" title="no title">Invert selection</label>'
29 + '<input name="associated" type="checkbox" value="1" id="nsassociated" title="no title" />'
30 + '<label for="nsassociated" title="no title">Associated namespace</label>'
31 + '<input type="submit" value="Go" />'
32 + '<input type="hidden" value="Special:RecentChanges" name="title" />'
35 var $env
= $( '<div>' ).html( select
).appendTo( 'body' );
37 // TODO abstract the double strictEquals
39 // At first checkboxes are enabled
40 strictEqual( $( '#nsinvert' ).attr( 'disabled' ), undefined );
41 strictEqual( $( '#nsassociated' ).attr( 'disabled' ), undefined );
43 // Initiate the recentchanges module
44 mw
.special
.recentchanges
.init();
47 strictEqual( $( '#nsinvert' ).attr( 'disabled' ), 'disabled' );
48 strictEqual( $( '#nsassociated' ).attr( 'disabled' ), 'disabled' );
50 // select second option...
51 var $options
= $( '#namespace' ).find( 'option' );
52 $options
.eq(0).removeAttr( 'selected' );
53 $options
.eq(1).attr( 'selected', 'selected' );
54 $( '#namespace' ).change();
56 // ... and checkboxes should be enabled again
57 strictEqual( $( '#nsinvert' ).attr( 'disabled' ), undefined );
58 strictEqual( $( '#nsassociated' ).attr( 'disabled' ), undefined );
60 // select first option ( 'all' namespace)...
61 $options
.eq(1).removeAttr( 'selected' );
62 $options
.eq(0).attr( 'selected', 'selected' );;
63 $( '#namespace' ).change();
65 // ... and checkboxes should now be disabled
66 strictEqual( $( '#nsinvert' ).attr( 'disabled' ), 'disabled' );
67 strictEqual( $( '#nsassociated' ).attr( 'disabled' ), 'disabled' );