r91387 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91386‎ | r91387 | r91388 >
Date:23:22, 3 July 2011
Author:krinkle
Status:ok
Tags:
Comment:
Adding tests for expected reponse when passing invalid values to Map.get
* These are currently @broken
* Map.get should (as documented) handle an object for multiple or a string for a single selection and return the value(s). Right now, however, the function returns the values object if the first two if-cases are not matched. It needs an additional check to verify that there are indeed no arguments passed.
* Adding comments in the test suite
Modified paths:
  • /trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.js (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.js
@@ -15,22 +15,28 @@
1616 });
1717
1818 test( 'mw.Map', function() {
19 - expect(15);
 19+ expect(17);
2020
2121 ok( mw.Map, 'mw.Map defined' );
2222
2323 var conf = new mw.Map(),
 24+ // Dummy variables
2425 funky = function() {},
2526 arry = [],
2627 nummy = 7;
2728
 29+ // Tests for input validation
2830 strictEqual( conf.get( 'inexistantKey' ), null, 'Map.get returns null if selection was a string and the key was not found' );
2931 strictEqual( conf.set( 'myKey', 'myValue' ), true, 'Map.set returns boolean true if a value was set for a valid key string' );
3032 strictEqual( conf.set( funky, 'Funky' ), false, 'Map.set returns boolean false if key was invalid (Function)' );
3133 strictEqual( conf.set( arry, 'Arry' ), false, 'Map.set returns boolean false if key was invalid (Array)' );
3234 strictEqual( conf.set( nummy, 'Nummy' ), false, 'Map.set returns boolean false if key was invalid (Number)' );
3335 equal( conf.get( 'myKey' ), 'myValue', 'Map.get returns a single value value correctly' );
 36+ // @broken (these currently return the values object)
 37+ strictEqual( conf.get( nummy ), null, 'Map.get ruturns null if selection was invalid (Number)' );
 38+ strictEqual( conf.get( funky ), null, 'Map.get ruturns null if selection was invalid (Function)' );
3439
 40+ // Multiple values at once
3541 var someValues = {
3642 'foo': 'bar',
3743 'lorem': 'ipsum',
@@ -49,6 +55,8 @@
5056
5157 strictEqual( conf.exists( 'foo' ), true, 'Map.exists returns boolean true if a key exists' );
5258 strictEqual( conf.exists( 'notExist' ), false, 'Map.exists returns boolean false if a key does not exists' );
 59+
 60+ // Interacting with globals and accessing the values object
5361 strictEqual( conf.get(), conf.values, 'Map.get returns the entire values object by reference (if called without arguments)' );
5462
5563 conf.set( 'globalMapChecker', 'Hi' );

Follow-up revisions

RevisionCommit summaryAuthorDate
r91388Fix for the broken tests introduced in r91387....krinkle23:24, 3 July 2011

Status & tagging log