diff --git a/tests/qunit/ext.uls.tests.js b/tests/qunit/ext.uls.tests.js index 5bfddb27..c3733a0f 100644 --- a/tests/qunit/ext.uls.tests.js +++ b/tests/qunit/ext.uls.tests.js @@ -35,4 +35,37 @@ // its direction cannot be acquired using the langdb utils. strictEqual( $.uls.data.getDir( 'als' ), 'ltr', 'The direction of custom MW language als is ltr.' ); } ); + + test( '-- User preferences', function () { + expect( 2 ); + + // 'gofanim' means "fonts" in Hebrew. + // Here it's used as a meaningless word, to test + // the preferences without changing anything useful. + var prefName = 'gofanim', + prefs = mw.uls.preferences(), + prefsToSave = {}, + readPrefs; + + prefsToSave[prefName] = { + 'fonts': { + 'qqy': 'Megafont' + }, + 'webfonts-enabled': true + }; + + prefs.set( prefName, prefsToSave ); + stop(); + prefs.save( function ( successSave ) { + start(); + ok( successSave, 'Options saving API did not produce an error.' ); + } ); + + readPrefs = prefs.get( prefName ); + strictEqual( readPrefs[prefName].fonts.qqy, 'Megafont', 'Correct value for the font name' ); + + // Delete old options + prefs.set( prefName, undefined ); + prefs.save(); + } ); }( jQuery ) );