');
expect(root.append('text')).toEqual(root);
expect(root.html()).toEqual('text');
});
it('should not append anything if parent node is not of type element', function() {
var root = jqLite(document.createDocumentFragment());
expect(root.append('
foo
')).toBe(root);
expect(root.children().length).toBe(0);
});
});
describe('remove', function(){
it('should remove', function(){
var root = jqLite('
abc
');
var span = root.find('span');
expect(span.remove()).toEqual(span);
expect(root.html()).toEqual('');
});
});
describe('after', function(){
it('should after', function(){
var root = jqLite('
');
var span = root.find('span');
expect(span.after('
')).toEqual(span);
expect(root.html().toLowerCase()).toEqual('
');
});
it('should allow taking text', function(){
var root = jqLite('
');
var span = root.find('span');
span.after('abc');
expect(root.html().toLowerCase()).toEqual('
abc');
});
});
describe('parent', function(){
it('should return parent or an empty set when no parent', function(){
var parent = jqLite('
'),
child = parent.find('p');
expect(parent.parent()).toBeTruthy();
expect(parent.parent().length).toEqual(0);
expect(child.parent().length).toBe(1);
expect(child.parent()[0]).toBe(parent[0]);
});
it('should return empty set when no parent', function(){
var element = jqLite('
abc
');
expect(element.parent()).toBeTruthy();
expect(element.parent().length).toEqual(0);
});
it('should return empty jqLite object when parent is a document fragment', function() {
//this is quite unfortunate but jQuery 1.5.1 behaves this way
var fragment = document.createDocumentFragment(),
child = jqLite('
foo
');
fragment.appendChild(child[0]);
expect(child[0].parentNode).toBe(fragment);
expect(child.parent().length).toBe(0);
});
});
describe('next', function(){
it('should return next sibling', function(){
var element = jqLite('
bi
');
var b = element.find('b');
var i = element.find('i');
expect(b.next()).toJqEqual([i]);
});
});
describe('find', function(){
it('should find child by name', function(){
var root = jqLite('
');
var innerDiv = root.find('div');
expect(innerDiv.length).toEqual(1);
expect(innerDiv.html()).toEqual('text');
});
});
});