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