<commit_before>const assert = require('assert');
const {handleRoutes, routeTo, __resetRouteHandler} = require('../src/routeHandler');

describe('routeHandler', function() {
  afterEach(function() {
    __resetRouteHandler();
  });

  it('should handle routes', function() {
    let called = false;
    handleRoutes(url => {
      called = true;
      assert.equal(url, '/route');
    });
    routeTo('/route');
    assert.equal(called, true);
  });

  it('should throw an error when no handler has been setup', function() {
    assert.throws(() => {
      routeTo('/route');
    });
  });

  it('should throw an error when trying to setup multiple handlers', function() {
    handleRoutes(url => {});
    assert.throws(() => {
      handleRoutes(url => {});
    });
  });
});
<commit_msg>Fix route-handler tests<commit_after>const assert = require('assert');
const {handleRoutes, routeTo, __resetRouteHandler} = require('../src/routeHandler');

describe('routeHandler', function() {
  afterEach(function() {
    __resetRouteHandler();
  });

  it('should handle routes', function() {
    let called = false;
    handleRoutes(url => {
      called = true;
      assert.equal(url, '/route');
    });
    routeTo('/route');
    assert.equal(called, true);
  });

  it('should not throw an error when no handler has been setup', function() {
    assert.doesNotThrow(() => {
      routeTo('/route');
    });
  });

  it('should only ever allow one handler', function() {
    let called = false;
    handleRoutes(url => called = true);
    handleRoutes(url => {});
    routeTo('/route');
    assert.ok(called);
  });
});

{'fraction_non_alphanumeric': 0.178328173374613, 'fraction_numerical': 0.0, 'mean_word_length': 3.391304347826087, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '4224303', 'n_tokens_mistral': 482, 'n_tokens_neox': 472, 'n_words': 113}