1 module( 'mediawiki.user', QUnit.newMwEnvironment() );
3 test( '-- Initial check', function() {
6 ok( mw.user, 'mw.user defined' );
10 test( 'options', function() {
13 ok( mw.user.options instanceof mw.Map, 'options instance of mw.Map' );
16 test( 'User login status', function() {
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.
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' );