<commit_before>import fs from 'fs';
import path from 'path';
import temp from 'temp';
import until from 'test-until';

import {cloneRepository} from './helpers';
import {writeFile, deleteFileOrFolder, fileExists, getTempDir, realPath} from '../lib/helpers';
import GithubPackage from '../lib/github-package';

describe('GithubPackage', function() {
  let atomEnv, workspace, project, commandRegistry, notificationManager, grammars, config, confirm, tooltips, styles;
  let getLoadSettings, configDirPath, deserializers;
  let githubPackage, contextPool;

  beforeEach(function() {
    console.log('be: 1');
    atomEnv = global.buildAtomEnvironment();
    workspace = atomEnv.workspace;
    project = atomEnv.project;
    commandRegistry = atomEnv.commands;
    deserializers = atomEnv.deserializers;
    notificationManager = atomEnv.notifications;
    tooltips = atomEnv.tooltips;
    config = atomEnv.config;
    confirm = atomEnv.confirm.bind(atomEnv);
    styles = atomEnv.styles;
    grammars = atomEnv.grammars;
    getLoadSettings = atomEnv.getLoadSettings.bind(atomEnv);
    configDirPath = path.join(__dirname, 'fixtures', 'atomenv-config');
    console.log('be: 2');

    githubPackage = new GithubPackage(
      workspace, project, commandRegistry, notificationManager, tooltips, styles, grammars, confirm, config,
      deserializers, configDirPath, getLoadSettings,
    );
    console.log('be: 3');

    sinon.stub(githubPackage, 'rerender').callsFake(callback => {
      console.log('calling the FAKE rerender!');
      if (callback) {
        console.log('there is a callback to call... initiiating a setTimeout');
        const handle = setTimeout(() => {
          console.log('Calling that callback from the setTimeout!');
          callback();
        }, 0);
        console.log('the setTimeout call returned a handle:', handle);
      }
    });
    console.log('be: 4');

    contextPool = githubPackage.getContextPool();
    console.log('be: 5');
  });

  afterEach(async function() {
    console.log('ae: 1');
    await githubPackage.deactivate();
    console.log('ae: 2');
    atomEnv.destroy();
    console.log('ae: 3');
  });

  async function contextUpdateAfter(chunk) {
    console.log('cae: 1');
    const updatePromise = githubPackage.getSwitchboard().getFinishActiveContextUpdatePromise();
    console.log('cae: 2');
    await chunk();
    console.log('cae: 3');
    return updatePromise;
  }

  describe('construction', function() {
    let githubPackage1;

    afterEach(async function() {<commit_msg>All the cool kids use process.nextTick<commit_after>import fs from 'fs';
import path from 'path';
import temp from 'temp';
import until from 'test-until';

import {cloneRepository} from './helpers';
import {writeFile, deleteFileOrFolder, fileExists, getTempDir, realPath} from '../lib/helpers';
import GithubPackage from '../lib/github-package';

describe('GithubPackage', function() {
  let atomEnv, workspace, project, commandRegistry, notificationManager, grammars, config, confirm, tooltips, styles;
  let getLoadSettings, configDirPath, deserializers;
  let githubPackage, contextPool;

  beforeEach(function() {
    console.log('be: 1');
    atomEnv = global.buildAtomEnvironment();
    workspace = atomEnv.workspace;
    project = atomEnv.project;
    commandRegistry = atomEnv.commands;
    deserializers = atomEnv.deserializers;
    notificationManager = atomEnv.notifications;
    tooltips = atomEnv.tooltips;
    config = atomEnv.config;
    confirm = atomEnv.confirm.bind(atomEnv);
    styles = atomEnv.styles;
    grammars = atomEnv.grammars;
    getLoadSettings = atomEnv.getLoadSettings.bind(atomEnv);
    configDirPath = path.join(__dirname, 'fixtures', 'atomenv-config');
    console.log('be: 2');

    githubPackage = new GithubPackage(
      workspace, project, commandRegistry, notificationManager, tooltips, styles, grammars, confirm, config,
      deserializers, configDirPath, getLoadSettings,
    );
    console.log('be: 3');

    sinon.stub(githubPackage, 'rerender').callsFake(callback => {
      console.log('calling the FAKE rerender!');
      if (callback) {
        console.log('there is a callback to call... initiiating a setTimeout');
        process.nextTick(() => {
          console.log('Calling that callback from the nextTick!');
          callback();
        });
        // const handle = setTimeout(() => {
        //   console.log('Calling that callback from the setTimeout!');
        //   callback();
        // }, 0);
        console.log('the setTimeout call returned a handle:', handle);
      }
    });
    console.log('be: 4');

    contextPool = githubPackage.getContextPool();
    console.log('be: 5');
  });

  afterEach(async function() {
    console.log('ae: 1');
    await githubPackage.deactivate();
    console.log('ae: 2');
    atomEnv.destroy();
    console.log('ae: 3');
  });

  async function contextUpdateAfter(chunk) {
    console.log('cae: 1');
    const updatePromise = githubPackage.getSwitchboard().getFinishActiveContextUpdatePromise();
    console.log('cae: 2');
    await chunk();
    console.log('cae: 3');
    return updatePromise;
  }

  describe('construction', function() {
    let githubPackage1;

    afterEach(async function() {
{'fraction_non_alphanumeric': 0.13265890437106317, 'fraction_numerical': 0.004962779156327543, 'mean_word_length': 3.7377938517179023, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '1333390', 'n_tokens_mistral': 1541, 'n_tokens_neox': 1506, 'n_words': 365}