<commit_before>describe('helpers', function() {
  it("url helper", function() {
    var view = new Thorax.View({
      template: '<a href="{{url "/a/{{b}}" expand-tokens=true}}"></a>'
    });
    view.render();
    expect(view.$('a').attr('href')).to.equal('#/a/');
    view.b = 'b';
    view.render();
    expect(view.$('a').attr('href')).to.equal('#/a/b');
    view.b = false;
    view.setModel(new Backbone.Model({
      b: 'c'
    }));
    expect(view.$('a').attr('href')).to.equal('#/a/c');

    var view = new Thorax.View({
      template: '<a href="{{url "a" b}}"></a>',
      b: 'c'
    });
    view.render();
    expect(view.$('a').attr('href')).to.equal('#a/c');
  });

  it("option hash required arguments for button and link", function() {
    var view = new Thorax.View({
      template: '{{#link href="a"}}{{/link}}{{#button method="b"}}{{/button}}'
    });
    view.render();
    expect(view.$('a').attr('href')).to.equal('#a');
    expect(view.$('button').attr('data-call-method')).to.equal('b');
  });

  it("multiple arguments to link", function() {
    var view = new Thorax.View({
      template: '{{#link a b c class="test"}}link{{/link}}',
      a: 'a',
      b: 'b',
      c: 'c'
    });
    view.render();
    expect(view.$('a').attr('href')).to.equal('#a/b/c');
  });

  it("expand-tokens in link", function() {
    var view = new Thorax.View({
      template: '{{#link "a/{{key}}"}}link{{/link}}',
      key: 'b'
    });
    view.render();
    expect(view.$('a').attr('href')).to.equal('#a/{{key}}');

    view = new Thorax.View({
      template: '{{#link "a/{{key}}" expand-tokens=true}}link{{/link}}',
      key: 'b'
    });
    view.render();
    expect(view.$('a').attr('href')).to.equal('#a/b');
    expect(view.$('a[expand-tokens]').length).to.equal(0);
  });

  it("button and link helpers", function() {
    var view = new Thorax.View({
      events: {
        testEvent: function() {}
      },
      someMethod: function() {},
      template: '{{#button "someMethod"}}Button{{/button}}{{#button trigger="testEvent"}}Button 2{{/button}}{{#link "href"}}content{{/link}}'
    });
    view.render();
    expect($(view.$('button')[0]).html()).to.equal('Button');
    expect($(view.$('button')[0]).attr('data-call-method')).to.equal('someMethod');
    expect($(view.$('button')[1]).attr('data-trigger-event')).to.equal('testEvent');
    expect(view.$('a').html()).to.equal('content');
    expect(view.$('a').attr('href')).to.equal('#href');
  });
});<commit_msg>Add check for handlebars noop existence<commit_after>describe('helpers', function() {
  it("url helper", function() {
    var view = new Thorax.View({
      template: '<a href="{{url "/a/{{b}}" expand-tokens=true}}"></a>'
    });
    view.render();
    expect(view.$('a').attr('href')).to.equal('#/a/');
    view.b = 'b';
    view.render();
    expect(view.$('a').attr('href')).to.equal('#/a/b');
    view.b = false;
    view.setModel(new Backbone.Model({
      b: 'c'
    }));
    expect(view.$('a').attr('href')).to.equal('#/a/c');

    var view = new Thorax.View({
      template: '<a href="{{url "a" b}}"></a>',
      b: 'c'
    });
    view.render();
    expect(view.$('a').attr('href')).to.equal('#a/c');
  });

  it("option hash required arguments for button and link", function() {
    var view = new Thorax.View({
      template: '{{#link href="a"}}{{/link}}{{#button method="b"}}{{/button}}'
    });
    view.render();
    expect(view.$('a').attr('href')).to.equal('#a');
    expect(view.$('button').attr('data-call-method')).to.equal('b');
  });

  it("multiple arguments to link", function() {
    var view = new Thorax.View({
      template: '{{#link a b c class="test"}}link{{/link}}',
      a: 'a',
      b: 'b',
      c: 'c'
    });
    view.render();
    expect(view.$('a').attr('href')).to.equal('#a/b/c');
  });

  it("expand-tokens in link", function() {
    var view = new Thorax.View({
      template: '{{#link "a/{{key}}"}}link{{/link}}',
      key: 'b'
    });
    view.render();
    expect(view.$('a').attr('href')).to.equal('#a/{{key}}');

    view = new Thorax.View({
      template: '{{#link "a/{{key}}" expand-tokens=true}}link{{/link}}',
      key: 'b'
    });
    view.render();
    expect(view.$('a').attr('href')).to.equal('#a/b');
    expect(view.$('a[expand-tokens]').length).to.equal(0);
  });

  it("button and link helpers", function() {
    var view = new Thorax.View({
      events: {
        testEvent: function() {}
      },
      someMethod: function() {},
      template: '{{#button "someMethod"}}Button{{/button}}{{#button trigger="testEvent"}}Button 2{{/button}}{{#link "href"}}content{{/link}}'
    });
    view.render();
    expect($(view.$('button')[0]).html()).to.equal('Button');
    expect($(view.$('button')[0]).attr('data-call-method')).to.equal('someMethod');
    expect($(view.$('button')[1]).attr('data-trigger-event')).to.equal('testEvent');
    expect(view.$('a').html()).to.equal('content');
    expect(view.$('a').attr('href')).to.equal('#href');
  });

  it('should have access to handlebars noop', function() {
    // Explicit verification that Handlebars is exposing this field.
    expect(Handlebars.VM.noop).to.exist;
  });
});
{'fraction_non_alphanumeric': 0.27816358024691357, 'fraction_numerical': 0.0019290123456790122, 'mean_word_length': 3.2886683209263854, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '2194219', 'n_tokens_mistral': 1807, 'n_tokens_neox': 1813, 'n_words': 293}