<commit_before>/*jshint newcap:false*/
import EmberView from "ember-views/views/view";
import run from "ember-metal/run_loop";
import EmberObject from "ember-runtime/system/object";
import { A } from "ember-runtime/system/native_array";

// import {expectAssertion} from "ember-metal/tests/debug_helpers";

import { get } from "ember-metal/property_get";
import { set } from "ember-metal/property_set";

import EmberHandlebars from "ember-handlebars-compiler";
var compile = EmberHandlebars.compile;

var view;

var originalLookup = Ember.lookup;

function appendView() {
  run(function() { view.appendTo('#qunit-fixture'); });
}

function registerRepeatHelper() {
  EmberHandlebars.helper('repeat', function(value, options) {
    var count = options.hash.count;
    var a = [];
    while(a.length < count) {
        a.push(value);
    }
    return a.join('');
  });
}

QUnit.module("Handlebars bound helpers", {
  setup: function() {
  },
  teardown: function() {
    run(function() {
      if (view) {
        view.destroy();
      }
    });
    Ember.lookup = originalLookup;
  }
});

test("should update bound helpers when properties change", function() {
  EmberHandlebars.helper('capitalize', function(value) {
    return value.toUpperCase();
  });

  view = EmberView.create({
    controller: EmberObject.create({name: "Brogrammer"}),
    template: compile("{{capitalize name}}")
  });

  appendView();

  equal(view.$().text(), 'BROGRAMMER', "helper output is correct");

  run(function() {<commit_msg>Add a test for a bug fixed on beta<commit_after>/*jshint newcap:false*/
import EmberView from "ember-views/views/view";
import run from "ember-metal/run_loop";
import EmberObject from "ember-runtime/system/object";
import { A } from "ember-runtime/system/native_array";

// import {expectAssertion} from "ember-metal/tests/debug_helpers";

import { get } from "ember-metal/property_get";
import { set } from "ember-metal/property_set";

import EmberHandlebars from "ember-handlebars-compiler";
var compile = EmberHandlebars.compile;

var view;

var originalLookup = Ember.lookup;

function appendView() {
  run(function() { view.appendTo('#qunit-fixture'); });
}

function registerRepeatHelper() {
  EmberHandlebars.helper('repeat', function(value, options) {
    var count = options.hash.count;
    var a = [];
    while(a.length < count) {
        a.push(value);
    }
    return a.join('');
  });
}

QUnit.module("Handlebars bound helpers", {
  setup: function() {
  },
  teardown: function() {
    run(function() {
      if (view) {
        view.destroy();
      }
    });
    Ember.lookup = originalLookup;
  }
});

test("primitives should work correctly", function() {
  view = EmberView.create({
    prims: Ember.A(["string", 12]),

    template: compile('{{#each view.prims}}{{#if this}}inside-if{{/if}}{{#with this}}inside-with{{/with}}{{/each}}')
  });

  appendView(view);

  equal(view.$().text(), 'inside-ifinside-withinside-ifinside-with');
});

test("should update bound helpers when properties change", function() {
  EmberHandlebars.helper('capitalize', function(value) {
    return value.toUpperCase();
  });

  view = EmberView.create({
    controller: EmberObject.create({name: "Brogrammer"}),
    template: compile("{{capitalize name}}")
  });

  appendView();

  equal(view.$().text(), 'BROGRAMMER', "helper output is correct");

  run(function() {
{'fraction_non_alphanumeric': 0.16538461538461538, 'fraction_numerical': 0.000591715976331361, 'mean_word_length': 4.130500758725342, 'pattern_counts': {'":': 0, '<': 5, '<?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': '13366', 'n_tokens_mistral': 1109, 'n_tokens_neox': 1072, 'n_words': 230}