<commit_before>import * as babili from './babili';
import * as configUtil from './util/config';

describe('babili function', () => {
  beforeEach(() => {
    spyOn(configUtil, 'getUserConfigFile').and.returnValue('fileContents');
  });

  it('should call main babili function', () => {
    const context = {
      rootDir: '/Users/noone/Projects/ionic-conference-app'
    };
    const configFile = 'configFileContents';

    return babili.babili(context, configFile).then(() => {
      expect(configUtil.getUserConfigFile).toHaveBeenCalledWith(context, babili.taskInfo, configFile);
    });
  });

  it('should throw if context does not have a rootDir', () => {
    const context = {};
    const configFile = 'configFileContents';

    expect(babili.babili(context, configFile)).toThrow();
  });
<commit_msg>test(babili): fix failing babili test<commit_after>import * as babili from './babili';
import * as configUtil from './util/config';
import * as crossSpawn from 'cross-spawn';
import { EventEmitter } from 'events';

describe('babili function', () => {
  const emitter = new EventEmitter();
  beforeEach(() => {
    spyOn(configUtil, 'getUserConfigFile').and.returnValue('fileContents');
    spyOn(crossSpawn, 'spawn').and.callFake(() => {
      return emitter;
    });
  });

  it('should call main babili function', () => {
    const context = {
      rootDir: '/Users/noone/Projects/ionic-conference-app'
    };
    const configFile = 'configFileContents';

    let pr = babili.babili(context, configFile);
    emitter.emit('close', 0);
    pr.then(() => {
      expect(configUtil.getUserConfigFile).toHaveBeenCalledWith(context, babili.taskInfo, configFile);
    });
  });

  it('should throw if context does not have a rootDir', () => {
    const context = {};
    const configFile = 'configFileContents';

    expect(babili.babili(context, configFile)).toThrow();
  });

{'fraction_non_alphanumeric': 0.15993623804463336, 'fraction_numerical': 0.0005313496280552603, 'mean_word_length': 3.9293193717277486, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, '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': '6467417', 'n_tokens_mistral': 590, 'n_tokens_neox': 571, 'n_words': 123}