<commit_before>import test from 'ava';
import { ACTIVITY_UPDATE, MODE_UPDATE } from '../constants/actionTypes';
import { MOVE, DRAW } from '../constants/modes';
import selectMode from './selectMode';
import { fakeFactory } from '../utils/test';

test('should abort any ongoing activity', t => {
  const Dispatcher = fakeFactory.getDispatcher();
  const Store = fakeFactory.getStore();
  Store.getMode.returns(DRAW);
  selectMode(Dispatcher, Store, DRAW);
  t.true(Dispatcher.dispatch.firstCall.calledWith({
    type: ACTIVITY_UPDATE,
    inProgress: false,
  }));
});

test('when the selected mode is not the current, it should change the mode', t => {
  const Dispatcher = fakeFactory.getDispatcher();
  const Store = fakeFactory.getStore();
  Store.getMode.returns(MOVE);
  selectMode(Dispatcher, Store, DRAW);
  t.true(Dispatcher.dispatch.secondCall.calledWith({
    type: MODE_UPDATE,
    mode: DRAW,
  }));
});

test('when selecting the currently active mode, it should not try to change the mode', t => {
  const Dispatcher = fakeFactory.getDispatcher();
  const Store = fakeFactory.getStore();
  Store.getMode.returns(MOVE);
  selectMode(Dispatcher, Store, MOVE);
  t.false(Dispatcher.dispatch.secondCall.calledWith({
    type: MODE_UPDATE,
    mode: MOVE,
  }));
});<commit_msg>Fix tests<commit_after>import test from 'ava';
import { ACTIVITY_UPDATE, MODE_UPDATE } from '../constants/actionTypes';
import { MOVE, DRAW } from '../constants/modes';
import selectMode from './selectMode';
import { fakeFactory } from '../utils/test';

test('should abort any ongoing activity', t => {
  const Dispatcher = fakeFactory.getDispatcher();
  const Store = fakeFactory.getStore();
  Store.getMode.returns(DRAW);
  selectMode(Dispatcher, Store, DRAW);
  t.true(Dispatcher.dispatch.firstCall.calledWith({
    type: ACTIVITY_UPDATE,
    inProgress: false,
  }));
});

test('when the selected mode is not the current, it should change the mode', t => {
  const Dispatcher = fakeFactory.getDispatcher();
  const Store = fakeFactory.getStore();
  Store.getMode.returns(MOVE);
  selectMode(Dispatcher, Store, DRAW);
  t.true(Dispatcher.dispatch.secondCall.calledWith({
    type: MODE_UPDATE,
    mode: DRAW,
  }));
});

test('when selecting the currently active mode, it should not try to change the mode', t => {
  const Dispatcher = fakeFactory.getDispatcher();
  const Store = fakeFactory.getStore();
  Store.getMode.returns(MOVE);
  selectMode(Dispatcher, Store, MOVE);
  t.true(Dispatcher.dispatch.calledOnce);
});
{'fraction_non_alphanumeric': 0.13745019920318724, 'fraction_numerical': 0.0, 'mean_word_length': 4.732876712328767, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '7635132', 'n_tokens_mistral': 774, 'n_tokens_neox': 752, 'n_words': 201}