');
      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('
')).toBe(root);
      expect(root.children().length).toBe(0);
    });
  });
  describe('prepend', function(){
    it('should prepend to empty', function(){
      var root = jqLite('
');
      expect(root.prepend('
abc')).toEqual(root);
      expect(root.html().toLowerCase()).toEqual('
abc');
    });
    it('should prepend to content', function(){
      var root = jqLite('
text
');
      expect(root.prepend('
abc')).toEqual(root);
      expect(root.html().toLowerCase()).toEqual('
abctext');
    });
    it('should prepend text to content', function(){
      var root = jqLite('
text
');
      expect(root.prepend('abc')).toEqual(root);
      expect(root.html().toLowerCase()).toEqual('abctext');
    });
  });
  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');
    });
  });
  describe('hide', function() {
    var element;
    afterEach(function() {
      if (element) dealoc(element);
    });
    it('should hide the element', function() {
      element = jqLite('
');
      expect(isCssVisible(element)).toBe(true);
      element.hide();
      expect(isCssVisible(element)).toBe(false);
    });
  });
  describe('show', function() {
    var element;
    afterEach(function() {
      if (element) dealoc(element);
      element.remove();
    });
    it('should show the element ', function() {
      element = jqLite('
');
      element[0].style.display = 'none';
      expect(isCssVisible(element)).toBe(false);
      element.show();
      expect(isCssVisible(element)).toBe(true);
    });
    it('should show previously hidden element and preserve the display value', function() {
      element = jqLite('
xx
');
      jqLite(document.body).append(element);
      element.hide();
      expect(isCssVisible(element)).toBe(false);
      element.show();
      expect(element[0].style.display).toBe('inline');
      expect(isCssVisible(element)).toBe(true);
      element[0].style.display = 'block';
      element.hide();
      expect(isCssVisible(element)).toBe(false);
      element.show();
      expect(isCssVisible(element)).toBe(true);
      // this totally doesn't make sense, it should be 'block', but jquery (1.4.2+1.6.2) behaves
      // this way.
      expect(element[0].style.display).toBe('inline');
    });
  });
  describe('eq', function() {
    it('should select the nth element ', function() {
      var element = jqLite('
aa
bb
');
      expect(element.find('span').eq(0).html()).toBe('aa');
      expect(element.find('span').eq(-1).html()).toBe('bb');
      expect(element.find('span').eq(20).length).toBe(0);;
    });
  });
});