<commit_before>import {expect} from 'chai';
import {List, fromJS} from 'immutable';
import React from 'react';
import TestUtils from 'react-addons-test-utils';

import {AddressFormSet} from '../../assets/js/components/AddressFormSet';
import MemberForm from '../../assets/js/components/MemberForm';

const {
  renderIntoDocument,
  scryRenderedDOMComponentsWithTag,
  findRenderedDOMComponentWithTag,
  scryRenderedDOMComponentsWithClass,
  scryRenderedComponentsWithType,
  Simulate
} = TestUtils;

const TableWrapper = React.createClass({
  render: function() {
    return (
      <table>{this.props.children}</table>
    )
  }
})

describe('Member Formset', () => {
  it('renders a specified number of MemberForms', () => {
    const members = fromJS([{
        name: '',
        address: '',
        latlng_dirty: true,
        latlng: undefined,
        party: '',
        id: '',
      }, {
        name: '',
        address: '',
        latlng_dirty: true,
        latlng: undefined,
        party: '',
        id: '',
      }, {
        name: '',
        address: '',
        latlng_dirty: true,
        latlng: undefined,
        party: '',
        id: '',
      }
    ])
    const component = renderIntoDocument(
      <AddressFormSet members={members} initial_forms={0} max_forms={7} action='/'
         method='post' csrftoken={window.csrftoken}/>
    )
    const memberforms = scryRenderedComponentsWithType(component, MemberForm)
    expect(memberforms.length).to.equal(members.size)
  })
})

describe('Member Form', () => {
  it('has the correct names for inputs', () => {
    const index = 3;
    const member = fromJS({
        name: '',
        address: '',
        latlng_dirty: true,
        latlng: undefined,
        party: '',
        id: '',
    })
    const component = renderIntoDocument(
      <TableWrapper>
        <MemberForm index={index} key={'form-member-'+index} member={member}/>
      </TableWrapper>
    )
    const inputs = scryRenderedDOMComponentsWithTag(component, 'input')
    const names = inputs.map((input) => input.name)
    expect(names).to.include("member_set-"+index+"-name")
    expect(names).to.include("member_set-"+index+"-id")
    expect(names).to.include("member_set-"+index+"-party")
  })

  it('has the correct name for textareas', () => {
    const index = 3;
    const member = fromJS({
        name: '',
        address: '',
        latlng_dirty: true,
        latlng: undefined,
        party: '',
        id: '',
    });
    const component = renderIntoDocument(
      <TableWrapper>
        <MemberForm index={index} key={'form-member-'+index} member={member}/>
      </TableWrapper>
    );
    const textarea = findRenderedDOMComponentWithTag(component, 'textarea')
    expect(textarea.name).to.equal("member_set-"+index+"-address")
  });

  it('displays the value contained in the member name and address', () => {
    const index = 3;
    const address = '70 Massachusetts Avenue';
    const name = 'MIT';
    const member = fromJS({
        name: name,
        address: address,
        latlng_dirty: true,
        latlng: undefined,
        party: '',
        id: '',
    });
    const component = renderIntoDocument(
      <TableWrapper>
        <MemberForm index={index} key={'form-member-'+index} member={member}/>
      </TableWrapper>
    );
    const textarea = findRenderedDOMComponentWithTag(component, 'textarea');
    const inputs = scryRenderedDOMComponentsWithTag(component, 'input');
    const input_values = inputs.map((input) => input.value)
    expect(input_values).to.include(name)
    expect(textarea.value).to.equal(address);

  })
})
<commit_msg>fix grammar in naming tests.<commit_after>import {expect} from 'chai';
import {List, fromJS} from 'immutable';
import React from 'react';
import TestUtils from 'react-addons-test-utils';

import {AddressFormSet} from '../../assets/js/components/AddressFormSet';
import MemberForm from '../../assets/js/components/MemberForm';

const {
  renderIntoDocument,
  scryRenderedDOMComponentsWithTag,
  findRenderedDOMComponentWithTag,
  scryRenderedDOMComponentsWithClass,
  scryRenderedComponentsWithType,
  Simulate
} = TestUtils;

const TableWrapper = React.createClass({
  render: function() {
    return (
      <table>{this.props.children}</table>
    )
  }
})

describe('Member Formset and children', () => {
  it('render a specified number of MemberForms', () => {
    const members = fromJS([{
        name: '',
        address: '',
        latlng_dirty: true,
        latlng: undefined,
        party: '',
        id: '',
      }, {
        name: '',
        address: '',
        latlng_dirty: true,
        latlng: undefined,
        party: '',
        id: '',
      }, {
        name: '',
        address: '',
        latlng_dirty: true,
        latlng: undefined,
        party: '',
        id: '',
      }
    ])
    const component = renderIntoDocument(
      <AddressFormSet members={members} initial_forms={0} max_forms={7} action='/'
         method='post' csrftoken={window.csrftoken}/>
    )
    const memberforms = scryRenderedComponentsWithType(component, MemberForm)
    expect(memberforms.length).to.equal(members.size)
  })
})

describe('Member Form', () => {
  it('have the correct names for inputs', () => {
    const index = 3;
    const member = fromJS({
        name: '',
        address: '',
        latlng_dirty: true,
        latlng: undefined,
        party: '',
        id: '',
    })
    const component = renderIntoDocument(
      <TableWrapper>
        <MemberForm index={index} key={'form-member-'+index} member={member}/>
      </TableWrapper>
    )
    const inputs = scryRenderedDOMComponentsWithTag(component, 'input')
    const names = inputs.map((input) => input.name)
    expect(names).to.include("member_set-"+index+"-name")
    expect(names).to.include("member_set-"+index+"-id")
    expect(names).to.include("member_set-"+index+"-party")
  })

  it('have the correct name for textareas', () => {
    const index = 3;
    const member = fromJS({
        name: '',
        address: '',
        latlng_dirty: true,
        latlng: undefined,
        party: '',
        id: '',
    });
    const component = renderIntoDocument(
      <TableWrapper>
        <MemberForm index={index} key={'form-member-'+index} member={member}/>
      </TableWrapper>
    );
    const textarea = findRenderedDOMComponentWithTag(component, 'textarea')
    expect(textarea.name).to.equal("member_set-"+index+"-address")
  });

  it('display the value contained in the member name and address', () => {
    const index = 3;
    const address = '70 Massachusetts Avenue';
    const name = 'MIT';
    const member = fromJS({
        name: name,
        address: address,
        latlng_dirty: true,
        latlng: undefined,
        party: '',
        id: '',
    });
    const component = renderIntoDocument(
      <TableWrapper>
        <MemberForm index={index} key={'form-member-'+index} member={member}/>
      </TableWrapper>
    );
    const textarea = findRenderedDOMComponentWithTag(component, 'textarea');
    const inputs = scryRenderedDOMComponentsWithTag(component, 'input');
    const input_values = inputs.map((input) => input.value)
    expect(input_values).to.include(name)
    expect(textarea.value).to.equal(address);

  })
})

{'fraction_non_alphanumeric': 0.14734100877192982, 'fraction_numerical': 0.001918859649122807, 'mean_word_length': 2.792619542619543, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 43, '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': '3953967', 'n_tokens_mistral': 2180, 'n_tokens_neox': 2162, 'n_words': 452}