<commit_before>import { expect } from 'chai';
import configureStore from '../../app/store/configure_store';
import * as Constants from '../../app/constants/following_constants';
import * as Actions from '../../app/actions/following_actions';
import { following } from '../../app/reducers/following_reducers';

describe ( 'Redux Reducers::Following', () => {

  describe ( 'initial state', () => {
    const initialState = {
      user1Compare: [],
      user2Compare: []
    };
    const undefinedAction = {
      type: undefined
    };

    it ( 'returns the initialState object', () => {
      expect( following( undefined, undefinedAction ) ).to.deep.equal( initialState );
    });
  });

  describe ( 'state after REQUEST_FOLLOWING action type', () => {
    const request = Actions.requestFollowing( 'jcolella48' );
    const requestReturnObj = {
      user1Compare: [],
      user2Compare: [],
      jcolella48: {
        isFetching: true,
        following: []
      }
    }

    it ( 'returns state object with user and its `isFetching` property as true', () => {
      expect( following( undefined, request ) ).to.deep.equal( requestReturnObj );
    });
  });

  describe ( 'state after RECEIVE_FOLLOWING action type', () => {
    const followingArray = ['kitsplit', 'kylemooney']
    const receiveAction = Actions.receiveFollowing( 'jcolella48', { array: followingArray } );
    const receiveReturnObj = {
      user1Compare: [],
      user2Compare: [],
      jcolella48: {
        isFetching: false,
        following: followingArray
      }
    };

    it ( 'returns state with user object containing isFetching property false and following property with array', () => {
      expect( following( undefined, receiveAction ) ).to.deep.equal( receiveReturnObj );
    });
  });

  describe ( 'state after async fetch action', () => {
    const users = ['jcolella48', 'sarahjeangilly'];
    const store = configureStore();
    store.dispatch( Actions.fetchFollowing( users ) )

    describe ( 'user1 object', () => {
      it ( 'returns user1 object with property name `jcolella48`', () => {
        expect( store.getState().following ).to.have.property( 'jcolella48' ).that.is.an( 'object' );
      });

      it ( 'returns user1 object with property isFetching', () => {
        expect( store.getState().following['jcolella48'] ).to.have.property( 'isFetching' ).that.is.a( 'boolean' );
      });

      describe ( 'user1 object::following array', () => {
        it ( 'returns user1 object with property following array', () => {
          expect( store.getState().following['jcolella48'] ).to.have.property( 'following' ).that.is.an( 'array' );
        });

        it ( 'following array contains friends from Twitter search; has length greater than 0', () => {
          expect( store.getState().following['jcolella48']['following'] ).to.have.length.above( 0 )
        });
      });

    });<commit_msg>try to work through thunk returning Promise in order to test async; no solution currently<commit_after>import { expect } from 'chai';
import configureStore from '../../app/store/configure_store';
import * as Constants from '../../app/constants/following_constants';
import * as Actions from '../../app/actions/following_actions';
import { following } from '../../app/reducers/following_reducers';

describe.only ( 'Redux Reducers::Following', () => {

  describe ( 'initial state', () => {
    const initialState = {
      user1Compare: [],
      user2Compare: []
    };
    const undefinedAction = {
      type: undefined
    };

    it ( 'returns the initialState object', () => {
      expect( following( undefined, undefinedAction ) ).to.deep.equal( initialState );
    });
  });

  describe ( 'state after REQUEST_FOLLOWING action type', () => {
    const request = Actions.requestFollowing( 'jcolella48' );
    const requestReturnObj = {
      user1Compare: [],
      user2Compare: [],
      jcolella48: {
        isFetching: true,
        following: []
      }
    }

    it ( 'returns state object with user and its `isFetching` property as true', () => {
      expect( following( undefined, request ) ).to.deep.equal( requestReturnObj );
    });
  });

  describe ( 'state after RECEIVE_FOLLOWING action type', () => {
    const followingArray = ['kitsplit', 'kylemooney']
    const receiveAction = Actions.receiveFollowing( 'jcolella48', { array: followingArray } );
    const receiveReturnObj = {
      user1Compare: [],
      user2Compare: [],
      jcolella48: {
        isFetching: false,
        following: followingArray
      }
    };

    it ( 'returns state with user object containing isFetching property false and following property with array', () => {
      expect( following( undefined, receiveAction ) ).to.deep.equal( receiveReturnObj );
    });
  });

  describe ( 'state after async fetch action', () => {
    const users = ['jcolella48', 'sarahjeangilly'];
    const store = configureStore();
    store.dispatch( Actions.fetchFollowing( users ) );

    describe ( 'user1 object', () => {
      it ( 'returns user1 object with property name `jcolella48`', () => {
        expect( store.getState().following ).to.have.property( 'jcolella48' ).that.is.an( 'object' );
      });

      it ( 'returns user1 object with property isFetching', () => {
        expect( store.getState().following['jcolella48'] ).to.have.property( 'isFetching' ).that.is.a( 'boolean' );
      });

      describe ( 'user1 object::following array', () => {
        it ( 'returns user1 object with property following array', () => {
          expect( store.getState().following['jcolella48'] ).to.have.property( 'following' ).that.is.an( 'array' );
        });

        it ( 'following array contains friends from Twitter search; has length greater than 0', () => {
          expect( store.getState().following['jcolella48']['following'] ).to.have.length.above( 0 )
        });
      });

    });
{'fraction_non_alphanumeric': 0.1524534686971235, 'fraction_numerical': 0.01116751269035533, 'mean_word_length': 2.9671140939597316, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, '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': '1189537', 'n_tokens_mistral': 1729, 'n_tokens_neox': 1648, 'n_words': 434}