Merge "Make sure that SQLite uses no prefix"
[lhc/web/wiklou.git] / tests / qunit / suites / resources / mediawiki.special / mediawiki.special.recentchanges.test.js
1 ( function ( mw, $ ) {
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
9 // from Special:Recentchanges
10 selectHtml =
11 '<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
28 $env = $( '<div>' ).html( selectHtml ).appendTo( 'body' );
29
30 // TODO abstract the double strictEquals
31
32 // At first checkboxes are enabled
33 assert.strictEqual( $( '#nsinvert' ).prop( 'disabled' ), false );
34 assert.strictEqual( $( '#nsassociated' ).prop( 'disabled' ), false );
35
36 // Initiate the recentchanges module
37 mw.special.recentchanges.init();
38
39 // By default
40 assert.strictEqual( $( '#nsinvert' ).prop( 'disabled' ), true );
41 assert.strictEqual( $( '#nsassociated' ).prop( 'disabled' ), true );
42
43 // select second option...
44 $options = $( '#namespace' ).find( 'option' );
45 $options.eq(0).removeProp( 'selected' );
46 $options.eq(1).prop( 'selected', true );
47 $( '#namespace' ).change();
48
49 // ... and checkboxes should be enabled again
50 assert.strictEqual( $( '#nsinvert' ).prop( 'disabled' ), false );
51 assert.strictEqual( $( '#nsassociated' ).prop( 'disabled' ), false );
52
53 // select first option ( 'all' namespace)...
54 $options.eq(1).removeProp( 'selected' );
55 $options.eq(0).prop( 'selected', true );
56 $( '#namespace' ).change();
57
58 // ... and checkboxes should now be disabled
59 assert.strictEqual( $( '#nsinvert' ).prop( 'disabled' ), true );
60 assert.strictEqual( $( '#nsassociated' ).prop( 'disabled' ), true );
61
62 // DOM cleanup
63 $env.remove();
64 });
65 }( mediaWiki, jQuery ) );