Localisation updates from http://translatewiki.net.
[mediawiki.git] / tests / qunit / suites / resources / mediawiki / mediawiki.user.test.js
blob15265db57dd22aedb27b3ad75bf85e5fa2726748
1 module( 'mediawiki.user', QUnit.newMwEnvironment() );
3 test( '-- Initial check', function() {
4         expect(1);
6         ok( mw.user, 'mw.user defined' );
7 });
10 test( 'options', function() {
11         expect(1);
13         ok( mw.user.options instanceof mw.Map, 'options instance of mw.Map' );
14 });
16 test( 'User login status', function() {
17         expect(5);
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          */
26         // Forge an anonymous user:
27         mw.config.set( 'wgUserName', null);
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' );
32         // Not part of startUp module
33         mw.config.set( 'wgUserName', 'John' );
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' );
38         equal( mw.user.id(), 'John', 'user.id Returns username when logged-in' );
39 });