<commit_before>/* Copyright (C) 2017 Canonical Ltd. */
'use strict';

const React = require('react');

const ButtonRow = require('./button-row');
const GenericButton = require('../generic-button/generic-button');

const jsTestUtils = require('../../utils/component-test-utils');

describe('ButtonRow', function() {

  it('generates a button', function() {
    var callbackStub = sinon.stub();
    var buttons = [{
      title: 'My button',
      type: 'submit',
      action: callbackStub
    }];
    var output = jsTestUtils.shallowRender(
      <ButtonRow
        buttons={buttons} />);
    assert.deepEqual(output.props.children, [
      <GenericButton
        action={callbackStub}
        disabled={undefined}
        key="My button"
        submit={undefined}
        type="submit">
        My button
      </GenericButton>]);
  });

  it('sets a class when generating multiple buttons', function() {
    var callbackStub = sinon.stub();
    var buttons = [{
      title: 'My button',
      type: 'submit',
      action: callbackStub
    }, {
      title: 'Another button',
      type: 'submit',
      action: callbackStub
    }];
    var output = jsTestUtils.shallowRender(
      <ButtonRow
        buttons={buttons} />);
    var children = [
      <GenericButton
        action={callbackStub}
        disabled={undefined}
        key="My button"
        submit={undefined}
        type="submit">
        My button
      </GenericButton>,
      <GenericButton
        action={callbackStub}
        disabled={undefined}
        key="Another button"
        submit={undefined}
        type="submit">
        Another button
      </GenericButton>
    ];
    assert.deepEqual(output,
      <div className="button-row button-row--multiple button-row--count-2">
        {children}
      </div>);
  });
});<commit_msg>Update button row tests to use enzyme.<commit_after>/* Copyright (C) 2017 Canonical Ltd. */
'use strict';

const React = require('react');
const enzyme = require('enzyme');

const ButtonRow = require('./button-row');
const GenericButton = require('../generic-button/generic-button');

describe('ButtonRow', function() {

  const renderComponent = (options = {}) => enzyme.shallow(
    <ButtonRow
      buttons={options.buttons || []} />
  );

  it('generates a button', function() {
    var callbackStub = sinon.stub();
    var buttons = [{
      title: '<NAME>',
      type: 'submit',
      action: callbackStub
    }];
    const wrapper = renderComponent({ buttons });
    const expected = (
      <div className="button-row button-row--multiple button-row--count-1">
        <GenericButton
          action={callbackStub}
          disabled={undefined}
          key="My button"
          submit={undefined}
          type="submit">
          My button
        </GenericButton>
      </div>
    );
    assert.compareJSX(wrapper, expected);
  });

  it('sets a class when generating multiple buttons', function() {
    var callbackStub = sinon.stub();
    var buttons = [{
      title: 'My button',
      type: 'submit',
      action: callbackStub
    }, {
      title: 'Another button',
      type: 'submit',
      action: callbackStub
    }];
    const wrapper = renderComponent({ buttons });
    const expected = (
      <div className="button-row button-row--multiple button-row--count-2">
        <GenericButton
          action={callbackStub}
          disabled={undefined}
          key="My button"
          submit={undefined}
          type="submit">
          My button
        </GenericButton>
        <GenericButton
          action={callbackStub}
          disabled={undefined}
          key="Another button"
          submit={undefined}
          type="submit">
          Another button
        </GenericButton>
      </div>);
    assert.compareJSX(wrapper, expected);
  });
});
{'fraction_non_alphanumeric': 0.13955928646379853, 'fraction_numerical': 0.0028856243441762854, 'mean_word_length': 2.3594713656387665, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 26, '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': '3228387', 'n_tokens_mistral': 1037, 'n_tokens_neox': 1032, 'n_words': 247}