<commit_before>import test from 'ava';
import { A, O } from 'boa-core';
import { init as initType } from '../src/';
import { History as HistoryType } from '../src/history';
import * as sinon from 'sinon';
import * as proxyquire from 'proxyquire';

test.beforeEach(t => {
  const sandbox = sinon.sandbox.create();
  const go = sandbox.stub();
  const start = sandbox.stub();
  const History = sandbox.stub();
  History.prototype.go = go;
  History.prototype.start = start;
  t.context.go = go;
  t.context.start = start;
  t.context.History = History;
  t.context.init = proxyquire('../src/', {
    './history': { History }
  }).init;
});

test(t => {
  t.plan(3);
  const init: typeof initType = t.context.init;
  const History: sinon.SinonStub = t.context.History;
  const go: sinon.SinonStub = t.context.go;
  const start: sinon.SinonStub = t.context.start;
  const routes = [];
  const action$ = O.empty<A<any>>();
  const options = { re: () => null };
  init({ routes }).handler(action$, options);
  t.ok(History.callCount === 1);
  t.ok(start.callCount === 0);
  t.ok(go.callCount === 0);
});

test(t => {
  t.plan(3);
  const init: typeof initType = t.context.init;
  const History: sinon.SinonStub = t.context.History;
  const go: sinon.SinonStub = t.context.go;
  const start: sinon.SinonStub = t.context.start;
  const routes = [];
  const action$ = O.of({ type: 'foo' });
  const options = { re: () => null };
  return init({ routes }).handler(action$, options).do(() => {
    t.ok(History.callCount === 1);
    t.ok(start.callCount === 1);
    t.ok(go.callCount === 0);
  });
});

test(t => {
  t.plan(4);
  const init: typeof initType = t.context.init;
  const History: sinon.SinonStub = t.context.History;
  const go: sinon.SinonStub = t.context.go;
  const start: sinon.SinonStub = t.context.start;
  const routes = [];
  const action$ = O.fromArray([
    { type: 'go-to', data: '/' },
    { type: 'foo' } // to run the .do operator
  ]);
  const options = { re: () => null };
  return init({ routes }).handler(action$, options).do(() => {
    t.ok(History.callCount === 1);
    t.ok(start.callCount === 1);
    t.ok(go.callCount === 1);
    t.same(go.getCall(0).args, ['/']);
  });
});<commit_msg>fix a test<commit_after>import test from 'ava';
import { A, O } from 'boa-core';
import { init as initType } from '../src/';
import { History as HistoryType } from '../src/history';
import * as sinon from 'sinon';
import * as proxyquire from 'proxyquire';

test.beforeEach(t => {
  const sandbox = sinon.sandbox.create();
  const go = sandbox.stub();
  const start = sandbox.stub();
  const History = sandbox.stub();
  History.prototype.go = go;
  History.prototype.start = start;
  t.context.go = go;
  t.context.start = start;
  t.context.History = History;
  t.context.init = proxyquire('../src/', {
    './history': { History }
  }).init;
});

test(t => {
  t.plan(3);
  const init: typeof initType = t.context.init;
  const History: sinon.SinonStub = t.context.History;
  const go: sinon.SinonStub = t.context.go;
  const start: sinon.SinonStub = t.context.start;
  const routes = [];
  const action$ = O.empty<A<any>>();
  const options = { re: () => null };
  init({ routes }).handler(action$, options);
  t.ok(History.callCount === 1);
  t.ok(start.callCount === 0);
  t.ok(go.callCount === 0);
});

test(t => {
  t.plan(3);
  const init: typeof initType = t.context.init;
  const History: sinon.SinonStub = t.context.History;
  const go: sinon.SinonStub = t.context.go;
  const start: sinon.SinonStub = t.context.start;
  const routes = [];
  const action$ = O.of({ type: 'foo' });
  const options = { re: () => null };
  return init({ routes }).handler(action$, options).do(() => {
    t.ok(History.callCount === 1);
    t.ok(start.callCount === 1);
    t.ok(go.callCount === 0);
  });
});

test(t => {
  t.plan(4);
  const init: typeof initType = t.context.init;
  const History: sinon.SinonStub = t.context.History;
  const go: sinon.SinonStub = t.context.go;
  const start: sinon.SinonStub = t.context.start;
  const routes = [];
  const action$ = O.from<A<any>>([
    { type: 'go-to', data: '/' },
    { type: 'foo' } // to run the .do operator
  ]);
  const options = { re: () => null };
  return init({ routes }).handler(action$, options).do(() => {
    t.ok(History.callCount === 1);
    t.ok(start.callCount === 1);
    t.ok(go.callCount === 1);
    t.same(go.getCall(0).args, ['/']);
  });
});
{'fraction_non_alphanumeric': 0.19755877034358046, 'fraction_numerical': 0.005877034358047016, 'mean_word_length': 3.2671166827386693, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 27, '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': '7608132', 'n_tokens_mistral': 1620, 'n_tokens_neox': 1606, 'n_words': 378}