import checkStore from '../../legacy/checkStore'; 

describe('checkStore', () => {
  it('should not throw if the store is valid', () => {
    const store = {
      dispatch: () => {},
      subscribe: () => {},
      getState: () => {},
      replaceReducer: () => {},
      runSaga: () => {},
      injectedReducers: {},
      injectedSagas: {}
    };

    expect(() => checkStore(store)).not.toThrow();
  });

  it('should throw if the store is missing methods', () => {
    const store = {
      dispatch: () => {},
      subscribe: () => {},
      // Missing getState and replaceReducer
      runSaga: () => {},
      injectedReducers: {},
      injectedSagas: {}
    };

    expect(() => checkStore(store)).toThrow(/Expected a valid redux store/);
  });

  it('should throw if methods are not functions', () => {
    const store = {
      dispatch: 'not a function',
      subscribe: () => {},
      getState: () => {},
      replaceReducer: () => {},
      runSaga: () => {},
      injectedReducers: {},
      injectedSagas: {}
    };

    expect(() => checkStore(store)).toThrow(/Expected a valid redux store/);
  });

  it('should throw if injectedReducers or injectedSagas are not objects', () => {
    const store = {
      dispatch: () => {},
      subscribe: () => {},
      getState: () => {},
      replaceReducer: () => {},
      runSaga: () => {},
      injectedReducers: 'not an object', // Incorrect type
      injectedSagas: () => {} // Incorrect type
    };

    expect(() => checkStore(store)).toThrow(/Expected a valid redux store/);
  });

  it('should throw if runSaga is not a function', () => {
    const store = {
      dispatch: () => {},
      subscribe: () => {},
      getState: () => {},
      replaceReducer: () => {},
      runSaga: {}, // Not a function
      injectedReducers: {},
      injectedSagas: {}
    };

    expect(() => checkStore(store)).toThrow(/Expected a valid redux store/);
  });
});