From bd8e38518fffa50a5efa4d2f29eec31497dd4e88 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 9 Oct 2016 20:24:48 -0700 Subject: [PATCH] Add more `_.isElement` tests. --- test/test.js | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/test/test.js b/test/test.js index 04fb7633a..d7a613b01 100644 --- a/test/test.js +++ b/test/test.js @@ -9237,22 +9237,25 @@ (function() { var args = arguments; - function Element() { - this.nodeType = 1; - } + QUnit.test('should return `true` for elements', function(assert) { + assert.expect(1); - QUnit.test('should return `false` for plain objects', function(assert) { - assert.expect(7); + if (document) { + assert.strictEqual(_.isElement(body), true); + } + else { + skipAssert(assert); + } + }); - var element = body || new Element; + QUnit.test('should return `true` for non-plain objects', function(assert) { + assert.expect(1); - assert.strictEqual(_.isElement(element), true); - assert.strictEqual(_.isElement({ 'nodeType': 1 }), false); - assert.strictEqual(_.isElement({ 'nodeType': Object(1) }), false); - assert.strictEqual(_.isElement({ 'nodeType': true }), false); - assert.strictEqual(_.isElement({ 'nodeType': [1] }), false); - assert.strictEqual(_.isElement({ 'nodeType': '1' }), false); - assert.strictEqual(_.isElement({ 'nodeType': '001' }), false); + function Foo() { + this.nodeType = 1; + } + + assert.strictEqual(_.isElement(new Foo), true); }); QUnit.test('should return `false` for non DOM elements', function(assert) { @@ -9280,6 +9283,17 @@ assert.strictEqual(_.isElement(symbol), false); }); + QUnit.test('should return `false` for plain objects', function(assert) { + assert.expect(6); + + assert.strictEqual(_.isElement({ 'nodeType': 1 }), false); + assert.strictEqual(_.isElement({ 'nodeType': Object(1) }), false); + assert.strictEqual(_.isElement({ 'nodeType': true }), false); + assert.strictEqual(_.isElement({ 'nodeType': [1] }), false); + assert.strictEqual(_.isElement({ 'nodeType': '1' }), false); + assert.strictEqual(_.isElement({ 'nodeType': '001' }), false); + }); + QUnit.test('should work with a DOM element from another realm', function(assert) { assert.expect(1); @@ -15033,7 +15047,7 @@ assert.deepEqual(actual.a, [[3, 4, 3]]); }); - QUnit.test('should merge plain-objects onto non plain-objects', function(assert) { + QUnit.test('should merge plain-objects onto non-plain objects', function(assert) { assert.expect(4); function Foo(object) {