import $, {VeamsQueryObject} from '../src';
test('prepend() - prepend element (HTML String)', () => {
document.body.innerHTML = `
text content 2
text content 2
text content 3
`;
const $targetEls: VeamsQueryObject = $('.target-el');
$targetEls.prepend('inserted element');
expect(document.querySelectorAll('strong')).toHaveLength(2);
expect($targetEls[0].firstChild.tagName).toBe('STRONG');
expect($targetEls[1].firstChild.tagName).toBe('STRONG');
});
test('prepend() - prepend element (VeamsQueryObject)', () => {
document.body.innerHTML = `
text content 2
text content 2
text content 3
`;
const $targetEls: VeamsQueryObject = $('.target-el');
const $insertEl: VeamsQueryObject = $('inserted element');
$targetEls.prepend($insertEl);
expect(document.querySelectorAll('strong')).toHaveLength(1);
expect($targetEls[1].firstChild.tagName).toBe('STRONG');
});
test('prepend() - prepend element (HTMLElement)', () => {
document.body.innerHTML = `
text content 2
text content 2
text content 3
`;
const $targetEls: VeamsQueryObject = $('.target-el');
const insertEl: HTMLElement = document.createElement('strong');
insertEl.textContent = 'inserted element';
$targetEls.prepend(insertEl);
expect(document.querySelectorAll('strong')).toHaveLength(1);
expect($targetEls[1].firstChild.tagName).toBe('STRONG');
});