<commit_before>var Fresh = require('../fresh-bundle.js'),
    React = require('react-tools').React,
    _ = require('underscore');

describe("Widget configuration", function() {

  it("should draw its widgets from the fresh.widgets namespace", function() {
    var EmptyWidget = {};
    Fresh.widgets.EmptyWidget = EmptyWidget;
    expect(Fresh.getWidgetByName('EmptyWidget')).toBe(EmptyWidget);
  });

  describe("for the root-level widget", function() {

    it("should render correct widget using Fresh.start", function() {
      var FakeWidgetInstance = {};
      Fresh.widgets.FakeWidget = jasmine.createSpy('FakeWidget')
                                        .andReturn(FakeWidgetInstance);
      // No need to interact with React at this point
      spyOn(React, 'renderComponent');
      Fresh.start({widget: 'FakeWidget'});
      expect(React.renderComponent.mostRecentCall.args[0]).toBe(FakeWidgetInstance);
    });

    it("should create widget with correct props using Fresh.start", function() {
      Fresh.widgets.FakeWidget = jasmine.createSpy('FakeWidget');
      spyOn(React, 'renderComponent');
      Fresh.start({
        widget: 'FakeWidget',
        foo: 'bar'
      });
      expect(Fresh.widgets.FakeWidget.mostRecentCall.args[0]).toEqual({
        widget: 'FakeWidget',
        foo: 'bar'
      });
    });

    it("should not alter props object sent to Fresh.start", function() {
      var initialProps = {widget: 'TestWidget', foo: 'bar'},
                         initialPropsClone = _.clone(initialProps);
      Fresh.widgets.TestWidget = React.createClass({
        render: function() {
          return '<span>nada</span>';
        }
      });
      spyOn(React, 'renderComponent');
      Fresh.start(initialProps, '<asdf>');
      expect(initialProps).toEqual(initialPropsClone);
      expect(React.renderComponent.mostRecentCall.args[0].props)
        .not.toBe(initialProps);
    });
  });
});<commit_msg>No need to have anything in render method that won't be called<commit_after>var Fresh = require('../fresh-bundle.js'),
    React = require('react-tools').React,
    _ = require('underscore');

describe("Widget configuration", function() {

  it("should draw its widgets from the fresh.widgets namespace", function() {
    var EmptyWidget = {};
    Fresh.widgets.EmptyWidget = EmptyWidget;
    expect(Fresh.getWidgetByName('EmptyWidget')).toBe(EmptyWidget);
  });

  describe("for the root-level widget", function() {

    it("should render correct widget using Fresh.start", function() {
      var FakeWidgetInstance = {};
      Fresh.widgets.FakeWidget = jasmine.createSpy('FakeWidget')
                                        .andReturn(FakeWidgetInstance);
      // No need to interact with React at this point
      spyOn(React, 'renderComponent');
      Fresh.start({widget: 'FakeWidget'});
      expect(React.renderComponent.mostRecentCall.args[0]).toBe(FakeWidgetInstance);
    });

    it("should create widget with correct props using Fresh.start", function() {
      Fresh.widgets.FakeWidget = jasmine.createSpy('FakeWidget');
      spyOn(React, 'renderComponent');
      Fresh.start({
        widget: 'FakeWidget',
        foo: 'bar'
      });
      expect(Fresh.widgets.FakeWidget.mostRecentCall.args[0]).toEqual({
        widget: 'FakeWidget',
        foo: 'bar'
      });
    });

    it("should not alter props object sent to Fresh.start", function() {
      var initialProps = {widget: 'TestWidget', foo: 'bar'},
                         initialPropsClone = _.clone(initialProps);
      Fresh.widgets.TestWidget = React.createClass({
        render: function() {}
      });
      spyOn(React, 'renderComponent');
      Fresh.start(initialProps, '<asdf>');
      expect(initialProps).toEqual(initialPropsClone);
      expect(React.renderComponent.mostRecentCall.args[0].props)
        .not.toBe(initialProps);
    });
  });
});
{'fraction_non_alphanumeric': 0.1409067490984029, 'fraction_numerical': 0.0015455950540958269, 'mean_word_length': 3.0030927835051546, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7129448', 'n_tokens_mistral': 1076, 'n_tokens_neox': 1058, 'n_words': 223}