@qntm-code/utils
Version:
A collection of useful utility functions with associated TypeScript types. All functions have been unit tested.
31 lines (30 loc) • 1.6 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const __1 = require("..");
const createElement_spec_1 = require("../test-helpers/createElement.spec");
describe('getNonInlineParent', () => {
describe('isDisplayInline', () => {
it('should return non linline parent for a text node', () => {
const element = (0, createElement_spec_1.createElement)('div');
element.innerHTML = 'text';
expect((0, __1.getNonInlineParent)(element.childNodes[0])).toEqual(element);
});
it('should return non linline parent for a native inline element', () => {
const element = (0, createElement_spec_1.createElement)('span');
const parent = (0, createElement_spec_1.createElement)('div');
parent.appendChild(element);
expect((0, __1.getNonInlineParent)(element)).toEqual(parent);
});
it('should return non linline parent for a native inline element (multiple levels)', () => {
const element = (0, createElement_spec_1.createElement)('span');
const parent = (0, createElement_spec_1.createElement)('span');
const grandparent = (0, createElement_spec_1.createElement)('div');
parent.appendChild(element);
grandparent.appendChild(parent);
expect((0, __1.getNonInlineParent)(element)).toEqual(grandparent);
});
it('should return null for an element with no parent', () => {
expect((0, __1.getNonInlineParent)(document.documentElement)).toEqual(null);
});
});
});