<commit_before>describe("Components implementing the ComponentTree mixin", function() {

  var _ = require('lodash'),
      jsdom = require('jsdom');

  // jsdom creates a fresh new window object for every test case and React needs
  // to be required *after* the window and document globals are available. The
  // var references however must be declared globally in order to be accessible
  // in test cases as well.
  var React,
      utils,
      Cosmos,
      componentClassSpec,
      ComponentClass,
      componentProps,
      componentElement,
      componentInstance;

  var renderComponent = function() {
    ComponentClass = React.createClass(componentClassSpec);
    componentElement = React.createElement(ComponentClass, componentProps);
    componentInstance = utils.renderIntoDocument(componentElement);
  };

  beforeEach(function() {
    global.window = jsdom.jsdom().createWindow('<html><body></body></html>');
    global.document = global.window.document;
    global.navigator = global.window.navigator;

    React = require('react/addons');
    utils = React.addons.TestUtils;
    Cosmos = require('../../build/cosmos.js');

    // The class spec and props will be extended or overriden in each test
    componentClassSpec = {
      mixins: [Cosmos.mixins.ComponentTree],

      render: function() {
        return React.DOM.span();
      }
    };
    componentProps = {};
  });

  describe("loading children", function() {

    beforeEach(function() {
      spyOn(Cosmos, 'createElement');
    });

    it("should use props from .children function", function() {
      componentClassSpec.children = {
        son: function() {
          return {
            component: 'Child',
            age: 13
          };
        }
      };

      renderComponent();
      componentInstance.loadChild('son');

      var createElementProps = Cosmos.createElement.calls.mostRecent().args[0];
      expect(createElementProps.component).toBe('Child');
      expect(createElementProps.age).toBe(13);
    });

    it("should default ref to .children key", function() {
      componentClassSpec.children = {
        son: function() {
          return {};
        }
      };

      renderComponent();
      componentInstance.loadChild('son');

      var createElementProps = Cosmos.createElement.calls.mostRecent().args[0];
      expect(createElementProps.ref).toBe('son');
    });

    it("should ref from .children function when specified", function() {
      componentClassSpec.children = {<commit_msg>Fix typo in test name #93<commit_after>describe("Components implementing the ComponentTree mixin", function() {

  var _ = require('lodash'),
      jsdom = require('jsdom');

  // jsdom creates a fresh new window object for every test case and React needs
  // to be required *after* the window and document globals are available. The
  // var references however must be declared globally in order to be accessible
  // in test cases as well.
  var React,
      utils,
      Cosmos,
      componentClassSpec,
      ComponentClass,
      componentProps,
      componentElement,
      componentInstance;

  var renderComponent = function() {
    ComponentClass = React.createClass(componentClassSpec);
    componentElement = React.createElement(ComponentClass, componentProps);
    componentInstance = utils.renderIntoDocument(componentElement);
  };

  beforeEach(function() {
    global.window = jsdom.jsdom().createWindow('<html><body></body></html>');
    global.document = global.window.document;
    global.navigator = global.window.navigator;

    React = require('react/addons');
    utils = React.addons.TestUtils;
    Cosmos = require('../../build/cosmos.js');

    // The class spec and props will be extended or overriden in each test
    componentClassSpec = {
      mixins: [Cosmos.mixins.ComponentTree],

      render: function() {
        return React.DOM.span();
      }
    };
    componentProps = {};
  });

  describe("loading children", function() {

    beforeEach(function() {
      spyOn(Cosmos, 'createElement');
    });

    it("should use props from .children function", function() {
      componentClassSpec.children = {
        son: function() {
          return {
            component: 'Child',
            age: 13
          };
        }
      };

      renderComponent();
      componentInstance.loadChild('son');

      var createElementProps = Cosmos.createElement.calls.mostRecent().args[0];
      expect(createElementProps.component).toBe('Child');
      expect(createElementProps.age).toBe(13);
    });

    it("should default ref to .children key", function() {
      componentClassSpec.children = {
        son: function() {
          return {};
        }
      };

      renderComponent();
      componentInstance.loadChild('son');

      var createElementProps = Cosmos.createElement.calls.mostRecent().args[0];
      expect(createElementProps.ref).toBe('son');
    });

    it("should use ref from .children function when specified", function() {
      componentClassSpec.children = {
{'fraction_non_alphanumeric': 0.11943561208267091, 'fraction_numerical': 0.0027821939586645467, 'mean_word_length': 2.8804934464148033, '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': '3205577', 'n_tokens_mistral': 1332, 'n_tokens_neox': 1288, 'n_words': 326}