From ed23b6b89da1d954486af27e32ee05171cc758f4 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 27 Dec 2015 23:59:04 -0600 Subject: [PATCH] Rearrange tests for consistency. --- test/test.js | 102 +++++++++++++++++++++++++-------------------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/test/test.js b/test/test.js index 2cfe112e7..ed3430ebd 100644 --- a/test/test.js +++ b/test/test.js @@ -2802,7 +2802,7 @@ assert.deepEqual(actual, [objects[1]]); }); - QUnit.test('should match properties when `object` is not a plain object', function(assert) { + QUnit.test('should work with a non-plain `object`', function(assert) { assert.expect(1); function Foo() { @@ -8978,6 +8978,15 @@ assert.deepEqual(actual, [false, true]); }); + QUnit.test('should work with a non-plain `object`', function(assert) { + assert.expect(1); + + function Foo(object) { lodashStable.assign(this, object); } + + var object = new Foo({ 'a': new Foo({ 'b': 1, 'c': 2 }) }); + assert.strictEqual(_.isMatch(object, { 'a': { 'b': 1 } }), true); + }); + QUnit.test('should partial match arrays', function(assert) { assert.expect(3); @@ -9081,15 +9090,6 @@ } }); - QUnit.test('should match properties when `object` is not a plain object', function(assert) { - assert.expect(1); - - function Foo(object) { lodashStable.assign(this, object); } - - var object = new Foo({ 'a': new Foo({ 'b': 1, 'c': 2 }) }); - assert.strictEqual(_.isMatch(object, { 'a': { 'b': 1 } }), true); - }); - QUnit.test('should match `undefined` values', function(assert) { assert.expect(3); @@ -11784,6 +11784,17 @@ assert.deepEqual(actual, [false, true]); }); + QUnit.test('should work with a non-plain `object`', function(assert) { + assert.expect(1); + + function Foo(object) { lodashStable.assign(this, object); } + + var object = new Foo({ 'a': new Foo({ 'b': 1, 'c': 2 }) }), + matches = _.matches({ 'a': { 'b': 1 } }); + + assert.strictEqual(matches(object), true); + }); + QUnit.test('should partial match arrays', function(assert) { assert.expect(3); @@ -11871,17 +11882,6 @@ } }); - QUnit.test('should match properties when `object` is not a plain object', function(assert) { - assert.expect(1); - - function Foo(object) { lodashStable.assign(this, object); } - - var object = new Foo({ 'a': new Foo({ 'b': 1, 'c': 2 }) }), - matches = _.matches({ 'a': { 'b': 1 } }); - - assert.strictEqual(matches(object), true); - }); - QUnit.test('should match `undefined` values', function(assert) { assert.expect(3); @@ -12207,6 +12207,17 @@ assert.deepEqual(actual, [false, true]); }); + QUnit.test('should work with a non-plain `srcValue`', function(assert) { + assert.expect(1); + + function Foo(object) { lodashStable.assign(this, object); } + + var object = new Foo({ 'a': new Foo({ 'b': 1, 'c': 2 }) }), + matches = _.matchesProperty('a', { 'b': 1 }); + + assert.strictEqual(matches(object), true); + }); + QUnit.test('should partial match arrays', function(assert) { assert.expect(3); @@ -12293,17 +12304,6 @@ } }); - QUnit.test('should match properties when `srcValue` is not a plain object', function(assert) { - assert.expect(1); - - function Foo(object) { lodashStable.assign(this, object); } - - var object = new Foo({ 'a': new Foo({ 'b': 1, 'c': 2 }) }), - matches = _.matchesProperty('a', { 'b': 1 }); - - assert.strictEqual(matches(object), true); - }); - QUnit.test('should match `undefined` values', function(assert) { assert.expect(2); @@ -12319,25 +12319,6 @@ assert.deepEqual(actual, expected); }); - QUnit.test('should return `false` when `object` is nullish', function(assert) { - assert.expect(2); - - var values = [, null, undefined], - expected = lodashStable.map(values, lodashStable.constant(false)); - - lodashStable.each(['constructor', ['constructor']], function(path) { - var matches = _.matchesProperty(path, 1); - - var actual = lodashStable.map(values, function(value, index) { - try { - return index ? matches(value) : matches(); - } catch (e) {} - }); - - assert.deepEqual(actual, expected); - }); - }); - QUnit.test('should match `undefined` values on primitives', function(assert) { assert.expect(2); @@ -12361,6 +12342,25 @@ delete numberProto.b; }); + QUnit.test('should return `false` when `object` is nullish', function(assert) { + assert.expect(2); + + var values = [, null, undefined], + expected = lodashStable.map(values, lodashStable.constant(false)); + + lodashStable.each(['constructor', ['constructor']], function(path) { + var matches = _.matchesProperty(path, 1); + + var actual = lodashStable.map(values, function(value, index) { + try { + return index ? matches(value) : matches(); + } catch (e) {} + }); + + assert.deepEqual(actual, expected); + }); + }); + QUnit.test('should return `true` when comparing a `srcValue` of empty arrays and objects', function(assert) { assert.expect(1);