* @class mw.Map
*
* @constructor
- * @param {boolean} [global=false] Whether to store the values in the global window
- * object or a exclusively in the object property 'values'.
+ * @param {Object|boolean} [values] Value-bearing object to map, or boolean
+ * true to map over the global object. Defaults to an empty object.
*/
- function Map( global ) {
- this.values = global === true ? window : {};
+ function Map( values ) {
+ this.values = values === true ? window : ( values || {} );
return this;
}
assert.strictEqual( window.mw, window.mediaWiki, 'mw alias to mediaWiki' );
} );
- QUnit.test( 'mw.Map', 27, function ( assert ) {
+ QUnit.test( 'mw.Map', 28, function ( assert ) {
var arry, conf, funky, globalConf, nummy, someValues;
conf = new mw.Map();
'lorem': 'ipsum'
}, 'Map.get returns multiple values correctly as an object' );
+ assert.deepEqual( conf, new mw.Map( conf.values ), 'new mw.Map maps over existing values-bearing object' );
+
assert.deepEqual( conf.get( ['foo', 'notExist'] ), {
'foo': 'bar',
'notExist': null