Krinkle has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/141937

Change subject: test: Add test for getObjectValues with inherited properties
......................................................................

test: Add test for getObjectValues with inherited properties

Increasing code coverage. Also remove bogus test for numbers
passed to this function; Garbage in, garabage out.

Change-Id: I6ca8943c23e49e49a2fba16f13b19c5855489309
---
M test/unit/core.test.js
1 file changed, 20 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/oojs/core refs/changes/37/141937/1

diff --git a/test/unit/core.test.js b/test/unit/core.test.js
index d14d985..6a91308 100644
--- a/test/unit/core.test.js
+++ b/test/unit/core.test.js
@@ -256,14 +256,14 @@
                var tmp;
 
                assert.deepEqual(
-                       oo.getObjectValues( { a: 1, b: 2, c: 3, foo: 'bar' } ),
-                       [ 1, 2, 3, 'bar' ],
-                       'Simple object with numbers and strings as values'
+                       oo.getObjectValues( { a: 1, b: false, foo: 'bar' } ),
+                       [ 1, false, 'bar' ],
+                       'Plain object with primitive values'
                );
                assert.deepEqual(
-                       oo.getObjectValues( [ 1, 2, 3, 'bar' ] ),
-                       [ 1, 2, 3, 'bar' ],
-                       'Simple array with numbers and strings as values'
+                       oo.getObjectValues( [ 1, false, 'bar' ] ),
+                       [ 1, false, 'bar' ],
+                       'Array with primitive values'
                );
 
                tmp = function () {
@@ -271,13 +271,24 @@
 
                        return this;
                };
-               tmp.a = 'foo';
-               tmp.b = 'bar';
+               tmp.a = 1;
+               tmp.b = false;
+               tmp.foo = 'bar';
 
                assert.deepEqual(
                        oo.getObjectValues( tmp ),
-                       [ 'foo', 'bar' ],
+                       [ 1, false, 'bar' ],
                        'Function with properties'
+               );
+
+               tmp = Object.create( { a: 1, b: false, foo: 'bar' } );
+               tmp.b = true;
+               tmp.bar = 'quux';
+
+               assert.deepEqual(
+                       oo.getObjectValues( tmp ),
+                       [ true, 'quux' ],
+                       'Only own properties'
                );
 
                assert.throws(
@@ -286,14 +297,6 @@
                        },
                        /^TypeError/,
                        'Throw exception for non-object (string)'
-               );
-
-               assert.throws(
-                       function () {
-                               oo.getObjectValues( 123 );
-                       },
-                       /^TypeError/,
-                       'Throw exception for non-object (number)'
                );
 
                assert.throws(

-- 
To view, visit https://gerrit.wikimedia.org/r/141937
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6ca8943c23e49e49a2fba16f13b19c5855489309
Gerrit-PatchSet: 1
Gerrit-Project: oojs/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to