<commit_before>//console.warn = jest.genMockFunction();

jest.unmock('../index');
jest.unmock('./webpackModules');
jest.unmock('redux');
jest.unmock('faker');

import faker from 'faker'

import { createStore, applyMiddleware, combineReducers } from 'redux'

import   webpackModules   from './webpackModules';
import actions, { auto, reducers, mergeReducers, after, filterSubStore, genStore } from '../index';

let middleware,store;

function RefrashStore(reset = true){
  // build 'auto' based on target files via Webpack

  reset && auto.reset();
  middleware = applyMiddleware( auto(webpackModules, webpackModules.keys()));
  store = createStore(combineReducers(reducers), middleware );
}

//=====================================================
//====================================== initialization
//=====================================================


describe('initialization', () => {

  let propName, actionName;

    beforeEach(function() {
      webpackModules.clear();
      propName   = faker.address.city();
      actionName = faker.address.streetName();
    });

//+ should throw when using mergeReducers before "auto"
//++++++++++++++++++++++++++++++++++++++++++++++++++++

    it('should throw when using mergeReducers before "auto"', () => {

      expect(() => {
        mergeReducers({foo:"bar"});
      }).toThrow(new RegExp("You are trying to get reducers before calling 'auto'. Trying moving applyMiddleware BEFORE combineReducers"));
    })

//+ should throw when using reducers before "auto"
//++++++++++++++++++++++++++++++++++++++++++++++++++++

    it('should throw when using reducers before "auto"', () => {

      expect(() => {
        Object.keys(reducers).forEach(propName=>reducers[propName]());
      }).toThrow(new RegExp("You are trying to get reducers before calling 'auto'. Trying moving applyMiddleware BEFORE combineReducers"));
    })

//+++++++++++ should have place holder action function
//++++++++++++++++++ for reducers to ref at build time

    it('should have a testing function', () => {

      webpackModules.set(propName,"index","default",(posts=[]) => posts );
      webpackModules.set(propName,actionName,"default",data => data );
      auto.reset();
      auto.testing({preOnly:true});
      auto(webpackModules, webpackModules.keys())
    })

//+++++++++++ should have place holder action function
//++++++++++++++++++ for reducers to ref at build time

    it('should have a settings function', () => {
        auto.settings({foo:"bar"})
    })

//+++++++++++ should have place holder action function
//++++++++++++++++++ for reducers to ref at build time

    it.skip('should have place holder action function for reducers to ref at build time', (done) => {

        webpackModules.set(propName,"index","default",(data=[]) => data );
        webpackModules.set(propName,actionName,"default",data => data );

        auto.testing({preOnly:true})
        auto(webpackModules, webpackModules.keys(),true)<commit_msg>more tests<commit_after>//console.warn = jest.genMockFunction();

jest.unmock('../index');
jest.unmock('./webpackModules');
jest.unmock('redux');
jest.unmock('faker');

import faker from 'faker'

import { createStore, applyMiddleware, combineReducers } from 'redux'

import   webpackModules   from './webpackModules';
import actions, { auto, reducers, mergeReducers, after, filterSubStore, genStore } from '../index';

import fsModules from './fsModules'

jest.mock('fs',  ()=>({
  lstatSync:(pathSt)=>({
    isDirectory:()=>true
  }),
  readdirSync:(pathSt,optsOb)=>{
    const name = "cats"
    const fullPath = "./store"+"/"+name
    if (pathSt === fullPath) {
        return [name]
    }
    return [{ isDirectory:()=>true, name:"cats" }]
  },
}));
jest.mock('path',()=>({join:(a,b)=>`${a}/${b}`,resolve:(path)=>path}));

let middleware,store;

function RefrashStore(reset = true){
  // build 'auto' based on target files via Webpack

  reset && auto.reset();
  middleware = applyMiddleware( auto(webpackModules, webpackModules.keys()));
  store = createStore(combineReducers(reducers), middleware );
}

//=====================================================
//====================================== utilities
//=====================================================


describe('utilities', () => {
  it('should manually load from files-system', () => {
    fsModules("./store")
  })
})

//=====================================================
//====================================== initialization
//=====================================================


describe('initialization', () => {

  let propName, actionName;

    beforeEach(function() {
      webpackModules.clear();
      propName   = faker.address.city();
      actionName = faker.address.streetName();
    });

//+ should throw when using mergeReducers before "auto"
//++++++++++++++++++++++++++++++++++++++++++++++++++++

    it('should throw when using mergeReducers before "auto"', () => {

      expect(() => {
        mergeReducers({foo:"bar"});
      }).toThrow(new RegExp("You are trying to get reducers before calling 'auto'. Trying moving applyMiddleware BEFORE combineReducers"));
    })

//+ should throw when using reducers before "auto"
//++++++++++++++++++++++++++++++++++++++++++++++++++++

    it('should throw when using reducers before "auto"', () => {

      expect(() => {
        Object.keys(reducers).forEach(propName=>reducers[propName]());
      }).toThrow(new RegExp("You are trying to get reducers before calling 'auto'. Trying moving applyMiddleware BEFORE combineReducers"));
    })

//+++++++++++ should have place holder action function
//++++++++++++++++++ for reducers to ref at build time

    it('should have a testing function', () => {

      webpackModules.set(propName,"index","default",(posts=[]) => posts );
      webpackModules.set(propName,actionName,"default",data => data );
      auto.reset();
      auto.testing({preOnly:true});
      const store = auto(webpackModules, webpackModules.keys())
    })

//+++++++++++++++++++++++++ should set on React-Native
//++++++++++++++++++ for reducers to ref at build time

    it('should set on React-Native', () => {

      const nativeStore = {
        [propName]:{
          [actionName]:{
            index:()=>{}
          }
        }
      }
      const store = auto(nativeStore)
    })
    
//+++++++++++ should have place holder action function
//++++++++++++++++++ for reducers to ref at build time

    it('should have a settings function', () => {
        auto.settings({foo:"bar"})
    })

//+++++++++++ should have place holder action function
//++++++++++++++++++ for reducers to ref at build time

    it.skip('should have place holder action function for reducers to ref at build time', (done) => {

        webpackModules.set(propName,"index","default",(data=[]) => data );
        webpackModules.set(propName,actionName,"default",data => data );

        auto.testing({preOnly:true})
        auto(webpackModules, webpackModules.keys(),true)
{'fraction_non_alphanumeric': 0.25851216022889845, 'fraction_numerical': 0.0, 'mean_word_length': 4.1746854182087345, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 41, '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': '3469382', 'n_tokens_mistral': 1986, 'n_tokens_neox': 1870, 'n_words': 464}