<commit_before>import { createStore } from 'redux';
import { _init } from '../listener';
import { ops, reset } from '../../test/mocks';
import { addBinderToStore } from '../redux/actions';
import { ensureState, ensureDispatch, ensureMountedBinder, isUnmountedBinder } from '../ensure';

describe('ensure', () => {

  describe('ensureState', () => {

    it('should not throw exception when state is ok', () => {
      const fn = () => ensureState();
      fn.should.not.throw(Error);
    });

    it('should throw exception when react-key state is not present', () => {
      _init({ store: createStore(() => ({}), {}) });
      const fn = () => ensureState();
      fn.should.throw(Error);
      _init(ops);
    });

  });

  describe('ensureDispatch', () => {

    it('should not throw exception when state is ok', () => {
      const fn = () => ensureDispatch();
      fn.should.not.throw(Error);
    });

    it('should throw exception when no state is present', () => {
      _init({ store: {} });
      const fn = () => ensureDispatch();
      fn.should.throw(Error);
      _init(ops);
    });

  });

  describe('ensureMountedBinder', () => {

    it('should not throw exception when binderId exists', () => {
      const binderId = 'myId';
      addBinderToStore({ id: binderId }, '');
      const fn = () => ensureMountedBinder(binderId);
      fn.should.not.throw(Error);
      reset();
    });

    it('should throw exception when binderId does not exist', () => {
      const binderId = 'myId';
      const fn = () => ensureMountedBinder(binderId);
      fn.should.throw(Error);
    });

  });

  describe('isUnmountedBinder', () => {

    it('return false when binder already exists', () => {
      const binderId = 'myId';
      addBinderToStore({ id: binderId }, '');
      isUnmountedBinder(binderId).should.be.false;
      reset();
    });

    it('return true when there is no binder in state', () => {
      reset();
      const binderId = 'myId';
      isUnmountedBinder(binderId).should.be.true;
    });

  });

});

<commit_msg>fix unit test<commit_after>import { createStore } from 'redux';
import { _init } from '../listener';
import { ops, reset } from '../../test/mocks';
import { addBinderToStore } from '../redux/actions';
import { ensureState, ensureDispatch, ensureMountedBinder, isUnmountedBinder } from '../ensure';

describe('ensure', () => {

  describe('ensureState', () => {

    it('should not throw exception when state is ok', () => {
      const fn = () => ensureState();
      fn.should.not.throw(Error);
    });

    it('should throw exception when react-key state is not present', () => {
      _init({ store: createStore(() => ({}), {}) });
      const fn = () => ensureState();
      fn.should.throw(Error);
      _init(ops);
    });

  });

  describe('ensureDispatch', () => {

    it('should not throw exception when state is ok', () => {
      const fn = () => ensureDispatch();
      fn.should.not.throw(Error);
    });

    it('should throw exception when no state is present', () => {
      _init({ store: {} });
      const fn = () => ensureDispatch();
      fn.should.throw(Error);
      _init(ops);
    });

  });

  describe('ensureMountedBinder', () => {

    it('should not throw exception when binderId exists', () => {
      const binderId = 'myId';
      addBinderToStore({ id: binderId }, '');
      const fn = () => ensureMountedBinder(binderId);
      fn.should.not.throw(Error);
      reset();
    });

    it('should throw exception when binderId does not exist', () => {
      const binderId = 'myId';
      ensureMountedBinder(binderId).should.be.false;
    });

  });

  describe('isUnmountedBinder', () => {

    it('return false when binder already exists', () => {
      const binderId = 'myId';
      addBinderToStore({ id: binderId }, '');
      isUnmountedBinder(binderId).should.be.false;
      reset();
    });

    it('return true when there is no binder in state', () => {
      reset();
      const binderId = 'myId';
      isUnmountedBinder(binderId).should.be.true;
    });

  });

});


{'fraction_non_alphanumeric': 0.18260014745637748, 'fraction_numerical': 0.0, 'mean_word_length': 2.796641791044776, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 42, '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': '7528969', 'n_tokens_mistral': 1270, 'n_tokens_neox': 1210, 'n_words': 291}