<commit_before>var tape = require("tape"),
    jsdom = require("jsdom"),
    d3 = Object.assign(require("../"), require("d3-selection"));

/*************************************
 ************ Components *************
 *************************************/

// Leveraging create hook with selection as first argument.
var checkboxHTML = `
      <label class="form-check-label">
        <input type="checkbox" class="form-check-input">
        <span class="checkbox-label-span"></span>
      </label>
    `,
    checkbox = d3.component("div", "form-check")
      .create(function (selection){
        selection.html(checkboxHTML);
      })
      .render(function (selection, props){
      });


/*************************************
 ************** Tests ****************
 *************************************/
tape("Create hook should pass selection on enter.", function(test) {
  var div = d3.select(jsdom.jsdom().body).append("div");
  div.call(checkbox);
  test.equal(div.html(), `<div class="form-check">${checkboxHTML}</div>`);
  test.end();
});
<commit_msg>Add more to test for selection in create hook.<commit_after>var tape = require("tape"),
    jsdom = require("jsdom"),
    d3 = Object.assign(require("../"), require("d3-selection"));

/*************************************
 ************ Components *************
 *************************************/

// Leveraging create hook with selection as first argument.
var checkboxHTML = `
      <label class="form-check-label">
        <input type="checkbox" class="form-check-input">
        <span class="checkbox-label-span"></span>
      </label>
    `,
    checkbox = d3.component("div", "form-check")
      .create(function (selection){
        selection.html(checkboxHTML);
      })
      .render(function (selection, props){
        if(props && props.label){
          selection.select(".checkbox-label-span")
              .text(props.label);
        }
      });


/*************************************
 ************** Tests ****************
 *************************************/
tape("Create hook should pass selection on enter.", function(test) {
  var div = d3.select(jsdom.jsdom().body).append("div");
  div.call(checkbox);
  test.equal(div.html(), `<div class="form-check">${checkboxHTML}</div>`);
  test.end();
});

tape("Render should have access to selection content from create hook.", function(test) {
  var div = d3.select(jsdom.jsdom().body).append("div");
  div.call(checkbox, { label: "My Checkbox"});
  test.equal(div.select(".checkbox-label-span").text(), "My Checkbox");
  test.end();
});

{'fraction_non_alphanumeric': 0.31121459060923556, 'fraction_numerical': 0.0034924330616996507, 'mean_word_length': 4.005825242718447, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '6917788', 'n_tokens_mistral': 720, 'n_tokens_neox': 702, 'n_words': 140}