mirror of
https://github.com/nunocoracao/blowfish.git
synced 2025-04-21 07:41:53 +02:00
31 lines
909 B
JavaScript
31 lines
909 B
JavaScript
|
QUnit.test( 'getParent', function( assert ) {
|
||
|
|
||
|
var getParent = fizzyUIUtils.getParent;
|
||
|
|
||
|
var gridA = document.querySelector('.grid-a');
|
||
|
var itemA1 = document.querySelector('.item-a1');
|
||
|
|
||
|
var parent = getParent( itemA1, '.grid' );
|
||
|
assert.equal( parent, gridA, 'got grid parent from item' );
|
||
|
|
||
|
parent = getParent( document.querySelector('.span-a3'), '.grid' );
|
||
|
assert.equal( parent, gridA, 'got grid parent from span' );
|
||
|
|
||
|
parent = getParent( itemA1, '#qunit' );
|
||
|
assert.ok( parent === undefined, 'parent not tree is undefined' );
|
||
|
|
||
|
var treeNotInDocument = document.createElement('div');
|
||
|
treeNotInDocument.innerHTML =
|
||
|
'<div class="a">' +
|
||
|
'<div class="a1">' +
|
||
|
'</div>';
|
||
|
|
||
|
parent = getParent( treeNotInDocument.querySelector('.a1'), '.not-found' );
|
||
|
|
||
|
assert.ok(
|
||
|
parent === undefined,
|
||
|
'Parent should be `undefined` even when the given tree is not in the document'
|
||
|
);
|
||
|
|
||
|
});
|