<commit_before>describe('collection helper', function() {
  it('should have access to handlebars noop', function() {
    // Explicit verification that Handlebars is exposing this field.
    expect(Handlebars.VM.noop).to.exist;
  });

  it("transition from no collection to collection", function() {
    var view = new Thorax.View({
      template: '{{#collection tag="ul"}}<li>{{letter}}</li>{{/collection}}'
    });
    view.render();
    expect(view.$('li').length).to.equal(0);
    var collection = new Thorax.Collection([{letter: 'a'}]);
    view.setCollection(collection);
    expect(view.$('li').length).to.equal(1);
    view.setCollection(false);
    expect(view.$('li').length).to.equal(0);
  });

  it("nested collection helper", function() {
    function testNesting(view, msg) {
      var blogModel = new Thorax.Model();
      view.setModel(blogModel);
      expect(view.$('[data-view-helper]').html()).to.equal('empty', msg + ' : starts empty');
      var authors = [
        new Thorax.Model({author: 'author 1'}),
        new Thorax.Model({author: 'author 2'})
      ];
      var comments1 = new Thorax.Collection([
        new Thorax.Model({
          comment: 'comment one',
          authors: new Thorax.Collection(authors)
        }),
        new Thorax.Model({
          comment: 'comment two',
          authors: new Thorax.Collection(authors)
        })
      ]);
      var comments2 = new Thorax.Collection([<commit_msg>Add test: collection helper won't re-render parent on add<commit_after>describe('collection helper', function() {
  it('should have access to handlebars noop', function() {
    // Explicit verification that Handlebars is exposing this field.
    expect(Handlebars.VM.noop).to.exist;
  });

  it("transition from no collection to collection", function() {
    var view = new Thorax.View({
      template: '{{#collection tag="ul"}}<li>{{letter}}</li>{{/collection}}'
    });
    view.render();
    expect(view.$('li').length).to.equal(0);
    var collection = new Thorax.Collection([{letter: 'a'}]);
    view.setCollection(collection);
    expect(view.$('li').length).to.equal(1);
    view.setCollection(false);
    expect(view.$('li').length).to.equal(0);
  });

  it("collection helper won't re-render parent on add", function() {
    var spy = this.spy();
    var collection = new Thorax.Collection([{letter: 'a'}]);
    var view = new Thorax.View({
      events: {
        rendered: spy
      },
      template: '{{#collection tag="ul"}}<li>{{letter}}</li>{{/collection}}'
    });
    view.render();
    expect(spy.callCount).to.equal(1);
    view.setCollection(collection);
    expect(spy.callCount).to.equal(1);
    expect(view.$('li').length).to.equal(1);
    collection.add({letter: 'b'});
    expect(spy.callCount).to.equal(1);
    expect(view.$('li').length).to.equal(2);
  });

  it("nested collection helper", function() {
    function testNesting(view, msg) {
      var blogModel = new Thorax.Model();
      view.setModel(blogModel);
      expect(view.$('[data-view-helper]').html()).to.equal('empty', msg + ' : starts empty');
      var authors = [
        new Thorax.Model({author: 'author 1'}),
        new Thorax.Model({author: 'author 2'})
      ];
      var comments1 = new Thorax.Collection([
        new Thorax.Model({
          comment: 'comment one',
          authors: new Thorax.Collection(authors)
        }),
        new Thorax.Model({
          comment: 'comment two',
          authors: new Thorax.Collection(authors)
        })
      ]);
      var comments2 = new Thorax.Collection([
{'fraction_non_alphanumeric': 0.17618913594145794, 'fraction_numerical': 0.0053475935828877, 'mean_word_length': 3.0478359908883825, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '5192512', 'n_tokens_mistral': 1084, 'n_tokens_neox': 1048, 'n_words': 230}