mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 02:17:48 +00:00
Add more _.isElement tests.
This commit is contained in:
42
test/test.js
42
test/test.js
@@ -9237,22 +9237,25 @@
|
|||||||
(function() {
|
(function() {
|
||||||
var args = arguments;
|
var args = arguments;
|
||||||
|
|
||||||
function Element() {
|
QUnit.test('should return `true` for elements', function(assert) {
|
||||||
this.nodeType = 1;
|
assert.expect(1);
|
||||||
}
|
|
||||||
|
|
||||||
QUnit.test('should return `false` for plain objects', function(assert) {
|
if (document) {
|
||||||
assert.expect(7);
|
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);
|
function Foo() {
|
||||||
assert.strictEqual(_.isElement({ 'nodeType': 1 }), false);
|
this.nodeType = 1;
|
||||||
assert.strictEqual(_.isElement({ 'nodeType': Object(1) }), false);
|
}
|
||||||
assert.strictEqual(_.isElement({ 'nodeType': true }), false);
|
|
||||||
assert.strictEqual(_.isElement({ 'nodeType': [1] }), false);
|
assert.strictEqual(_.isElement(new Foo), true);
|
||||||
assert.strictEqual(_.isElement({ 'nodeType': '1' }), false);
|
|
||||||
assert.strictEqual(_.isElement({ 'nodeType': '001' }), false);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test('should return `false` for non DOM elements', function(assert) {
|
QUnit.test('should return `false` for non DOM elements', function(assert) {
|
||||||
@@ -9280,6 +9283,17 @@
|
|||||||
assert.strictEqual(_.isElement(symbol), false);
|
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) {
|
QUnit.test('should work with a DOM element from another realm', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
@@ -15033,7 +15047,7 @@
|
|||||||
assert.deepEqual(actual.a, [[3, 4, 3]]);
|
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);
|
assert.expect(4);
|
||||||
|
|
||||||
function Foo(object) {
|
function Foo(object) {
|
||||||
|
|||||||
Reference in New Issue
Block a user