merge JSTesting branch into trunk
[lhc/web/wiklou.git] / tests / qunit / suites / resources / mediawiki / mediawiki.user.test.js
1 module( 'mediawiki.user', QUnit.newMwEnvironment() );
2
3 test( '-- Initial check', function() {
4 expect(1);
5
6 ok( mw.user, 'mw.user defined' );
7 });
8
9
10 test( 'options', function() {
11 expect(1);
12
13 ok( mw.user.options instanceof mw.Map, 'options instance of mw.Map' );
14 });
15
16 test( 'User login status', function() {
17 expect(5);
18
19 /**
20 * Tests can be run under three different conditions:
21 * 1) From tests/qunit/index.html, user will be anonymous.
22 * 2) Logged in on [[Special:JavaScriptTest/qunit]]
23 * 3) Anonymously at the same special page.
24 */
25
26 // Forge an anonymous user:
27 mw.config.set( 'wgUserName', null);
28
29 strictEqual( mw.user.name(), null, 'user.name should return null when anonymous' );
30 ok( mw.user.anonymous(), 'user.anonymous should reutrn true when anonymous' );
31
32 // Not part of startUp module
33 mw.config.set( 'wgUserName', 'John' );
34
35 equal( mw.user.name(), 'John', 'user.name returns username when logged-in' );
36 ok( !mw.user.anonymous(), 'user.anonymous returns false when logged-in' );
37
38 equal( mw.user.id(), 'John', 'user.id Returns username when logged-in' );
39 });