<commit_before>import React from 'react';
import SkinDeep from 'skin-deep';
import { expect } from 'chai';
import sinon from 'sinon';

import ContributionsFields from '../../../src/js/edu-benefits/components/military-history/ContributionsFields';
import { createVeteran } from '../../../src/js/edu-benefits/utils/veteran';

describe('<ContributionsFields>', () => {
  it('should set ExpandingGroup closed', () => {
    let data = createVeteran();
    data.activeDutyRepaying = false;
    const onStateChange = sinon.spy();

    const tree = SkinDeep.shallowRender(
      <ContributionsFields
          data={data}
          onStateChange={onStateChange}/>
    );

    expect(tree.subTree('ExpandingGroup').props.open).to.be.false;
  });
  it('should set ExpandingGroup open', () => {
    let data = createVeteran();
    data.activeDutyRepaying = true;
    const onStateChange = sinon.spy();

    const tree = SkinDeep.shallowRender(
      <ContributionsFields
          data={data}
          onStateChange={onStateChange}/>
    );

    expect(tree.subTree('ExpandingGroup').props.open).to.be.true;
  });
});
<commit_msg>add more complete unit tests for contributionsfields<commit_after>import React from 'react';
import SkinDeep from 'skin-deep';
import { expect } from 'chai';
import sinon from 'sinon';
import _ from 'lodash';

import ContributionsFields from '../../../src/js/edu-benefits/components/military-history/ContributionsFields';
import { createVeteran } from '../../../src/js/edu-benefits/utils/veteran';

function testGroup(conditions, index, result) {
  const veteran = createVeteran();
  const data = _.merge(veteran, conditions);
  const onStateChange = sinon.spy();
  const tree = SkinDeep.shallowRender(
    <ContributionsFields
        data={data}
        onStateChange={onStateChange}/>
  );
  expect(tree.everySubTree('ExpandingGroup')[index].props.open).to.be[result];
}

describe('<ContributionsFields>', () => {
  it('active duty kicker\'s ExpandingGroup should be closed if conditions are not met', () => {
    testGroup({ activeDutyKicker: false }, 0, 'false');
  });
  it('active duty kicker\'s ExpandingGroup should be open if conditions are met', () => {
    testGroup({
      activeDutyKicker: true,
      benefitsRelinquished: { value: 'chapter1606' }
    }, 0, 'true');
  });

  it('reserve kicker\'s ExpandingGroup should be closed if conditions are not met', () => {
    testGroup({ activeDutyKicker: false }, 1, 'false');
  });
  it('reserve kicker\'s ExpandingGroup should be open if conditions are met', () => {
    testGroup({
      reserveKicker: true,
      benefitsRelinquished: { value: 'chapter30' }
    }, 1, 'true');
  });

  it('activeDutyRepaying\'s ExpandingGroup should be closed if unchecked', () => {
    testGroup({ activeDutyRepaying: false }, 2, 'false');
  });
  it('activeDutyRepaying\'s ExpandingGroup should be open if checked', () => {
    testGroup({ activeDutyRepaying: true }, 2, 'true');
  });
});

{'fraction_non_alphanumeric': 0.15327481431465226, 'fraction_numerical': 0.004051316677920324, 'mean_word_length': 3.8022690437601296, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 18, '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': '1371545', 'n_tokens_mistral': 948, 'n_tokens_neox': 897, 'n_words': 212}