From: Krinkle Date: Sun, 3 Jul 2011 23:22:50 +0000 (+0000) Subject: Adding tests for expected reponse when passing invalid values to Map.get X-Git-Tag: 1.31.0-rc.0~29092 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=153c4c2221d8216599ce53ebe47220f8d542df5e;p=lhc%2Fweb%2Fwiklou.git 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 --- diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.js b/tests/qunit/suites/resources/mediawiki/mediawiki.js index 993150100b..d77c4b5a55 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.js @@ -15,22 +15,28 @@ test( '-- Initial check', function() { }); test( 'mw.Map', function() { - expect(15); + expect(17); ok( mw.Map, 'mw.Map defined' ); var conf = new mw.Map(), + // Dummy variables funky = function() {}, arry = [], nummy = 7; + // Tests for input validation strictEqual( conf.get( 'inexistantKey' ), null, 'Map.get returns null if selection was a string and the key was not found' ); strictEqual( conf.set( 'myKey', 'myValue' ), true, 'Map.set returns boolean true if a value was set for a valid key string' ); strictEqual( conf.set( funky, 'Funky' ), false, 'Map.set returns boolean false if key was invalid (Function)' ); strictEqual( conf.set( arry, 'Arry' ), false, 'Map.set returns boolean false if key was invalid (Array)' ); strictEqual( conf.set( nummy, 'Nummy' ), false, 'Map.set returns boolean false if key was invalid (Number)' ); equal( conf.get( 'myKey' ), 'myValue', 'Map.get returns a single value value correctly' ); + // @broken (these currently return the values object) + strictEqual( conf.get( nummy ), null, 'Map.get ruturns null if selection was invalid (Number)' ); + strictEqual( conf.get( funky ), null, 'Map.get ruturns null if selection was invalid (Function)' ); + // Multiple values at once var someValues = { 'foo': 'bar', 'lorem': 'ipsum', @@ -49,6 +55,8 @@ test( 'mw.Map', function() { strictEqual( conf.exists( 'foo' ), true, 'Map.exists returns boolean true if a key exists' ); strictEqual( conf.exists( 'notExist' ), false, 'Map.exists returns boolean false if a key does not exists' ); + + // Interacting with globals and accessing the values object strictEqual( conf.get(), conf.values, 'Map.get returns the entire values object by reference (if called without arguments)' ); conf.set( 'globalMapChecker', 'Hi' );