<commit_before>describe('jTextShorten', function () {
  var elem;

  beforeEach(function() {
    loadFixtures("single_element.html");
    element = $('.example');
  });

  describe('Initialization', function() {
    describe('Default settings', function() {
      var data;

      beforeEach(function() {
        $(element).shortened();
        data = $(element).data('shortened');
      });

      it('cached values should not be null/undefined', function() {
        expect(data).not.toBeNull();
        expect(data).not.toBeUndefined();
      });

      it('key elements in data attribute', function() {
        var keys = Object.keys(data);

        expect(keys.length).toEqual(3);
        expect(keys).toContain('lessText');
        expect(keys).toContain('limitChars');
        expect(keys).toContain('moreText');
        expect(keys).not.toContain('helloworld');
      });

      it('#limitChars', function() {
        expect(data.limitChars).toEqual(300);
      });

      it('#lessText', function() {
        expect(data.lessText).toEqual('See less');
      });

      it('#moreText', function() {
        expect(data.moreText).toEqual('See more');
      });
    });

    describe('Override default settings if options passed in', function() {
      var data;

      beforeEach(function() {
        $(element).shortened({
          lessText:          'View less',
          limitChars:        100,
          moreText:          'View more'
        });
        data = $(element).data('shortened');
      });

      it('cached values should not be null/undefined', function() {
        expect(data).not.toBe(null);
        expect(data).not.toBe(undefined);
      });

      it('key elements in data attribute', function() {
        var keys = Object.keys(data);

        expect(keys.length).toEqual(3);
        expect(keys).toContain('lessText');
        expect(keys).toContain('limitChars');
        expect(keys).toContain('moreText');
        expect(keys).not.toContain('helloworld');
      });

      it('#limitChars', function() {
        expect(data.limitChars).toEqual(100);
      });

      it('#lessText', function() {
        expect(data.lessText).toEqual('View less');
      });

      it('#moreText', function() {
        expect(data.moreText).toEqual('View more');
      });
    });

    it('should add custom classes to the element', function() {
      $(element).shortened();
      expect(element).toHaveClass('ui-shortened');
    });
  });

  describe('Destroy', function() {
    var orig_element;

    beforeEach(function() {
      $(element).shortened();
      orig_element = $(element).shortened('destroy');
    });

    it('should remove default class added', function() {
      expect(orig_element).not.toHaveClass('ui-shortened');
    });

    it('should have zero html tags added', function() {
      expect(orig_element.siblings('.ui-see_more')).toHaveLength(0);
    });

    it('should remove retained settings in data-attribute', function() {
      expect(orig_element.data('shortened')).toBeUndefined();
    });
  });
});<commit_msg>Add test cases for single element<commit_after>describe('jTextShorten', function () {
  var elem;

  beforeEach(function() {
    loadFixtures("single_element.html");
    element = $('.example');
  });

  describe('Initialization', function() {
    describe('Default settings', function() {
      var data;

      beforeEach(function() {
        $(element).shortened();
        data = $(element).data('shortened');
      });

      it('cached values should not be null/undefined', function() {
        expect(data).not.toBeNull();
        expect(data).not.toBeUndefined();
      });

      it('key elements in data attribute', function() {
        var keys = Object.keys(data);

        expect(keys.length).toEqual(3);
        expect(keys).toContain('lessText');
        expect(keys).toContain('limitChars');
        expect(keys).toContain('moreText');
        expect(keys).not.toContain('helloworld');
      });

      it('#limitChars', function() {
        expect(data.limitChars).toEqual(300);
      });

      it('#lessText', function() {
        expect(data.lessText).toEqual('See less');
      });

      it('#moreText', function() {
        expect(data.moreText).toEqual('See more');
      });
    });

    describe('Override default settings if options passed in', function() {
      var data;

      beforeEach(function() {
        $(element).shortened({
          lessText:          'View less',
          limitChars:        100,
          moreText:          'View more'
        });
        data = $(element).data('shortened');
      });

      it('cached values should not be null/undefined', function() {
        expect(data).not.toBe(null);
        expect(data).not.toBe(undefined);
      });

      it('key elements in data attribute', function() {
        var keys = Object.keys(data);

        expect(keys.length).toEqual(3);
        expect(keys).toContain('lessText');
        expect(keys).toContain('limitChars');
        expect(keys).toContain('moreText');
        expect(keys).not.toContain('helloworld');
      });

      it('#limitChars', function() {
        expect(data.limitChars).toEqual(100);
      });

      it('#lessText', function() {
        expect(data.lessText).toEqual('View less');
      });

      it('#moreText', function() {
        expect(data.moreText).toEqual('View more');
      });
    });

    it('should add custom classes to the element', function() {
      $(element).shortened();
      expect(element).toHaveClass('ui-shortened');
    });
  });

  describe('Destroy', function() {
    var orig_element;

    beforeEach(function() {
      $(element).shortened();
      orig_element = $(element).shortened('destroy');
    });

    it('should remove default class added', function() {
      expect(orig_element).not.toHaveClass('ui-shortened');
    });

    it('should have zero html tags added', function() {
      expect(orig_element.siblings('.ui-see_more')).toHaveLength(0);
    });

    it('should remove retained settings in data-attribute', function() {
      expect(orig_element.data('shortened')).toBeUndefined();
    });
  });

  it('support single element', function() {
    $('.example').shortened();

    expect($('.example')).toHaveLength(1);
    expect($('.example').data('shortened')).toHaveLength(1);
  });
});
{'fraction_non_alphanumeric': 0.17437273157645575, 'fraction_numerical': 0.004102887801798958, 'mean_word_length': 2.7021028037383177, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '323605', 'n_tokens_mistral': 1818, 'n_tokens_neox': 1761, 'n_words': 312}