<commit_before>import expect from 'expect';

import findRouteByComponent from '../../src/util/findRouteByComponent';

describe('findRouteByComponent', () => {
  const component = () => {};
  it('Returns undefined for empty routes', () => {
    expect(findRouteByComponent(component, [])).toMatch({});
  });
  it('Returns the first matched route', () => {
    const routes = [
      {
        component: function notThisOne() {},
      },
      {
        component,
      },
    ];
    expect(findRouteByComponent(component, routes)).toMatch({ route: routes[1] });
  });
});<commit_msg>Adds more tests and better test labels<commit_after>import expect from 'expect';

import findRouteByComponent from '../../src/util/findRouteByComponent';

describe('findRouteByComponent', () => {
  const component = () => {};
  it('Returns an empty object for empty routes', () => {
    expect(findRouteByComponent(component, [])).toEqual({});
  });
  it('Returns an empty object when the component cannot be found among the routes', () => {
    const routes = [
      {
        component: function notThisOne() {},
      },
      {
        component: function andNotThisOnceEither() {},
      },
    ];
    expect(findRouteByComponent(component, routes)).toEqual({});
  });
  it('Returns the first matched route', () => {
    const routes = [
      {
        component: function notThisOne() {},
      },
      {
        component,
      },
    ];
    expect(findRouteByComponent(component, routes)).toEqual({ route: routes[1] });
  });
  it('Handles `components` for named routes', () => {
    const routes = [
      {
        component: function ARouteHandler() {},
      },
      {
        components: {
          a: function AScreen() {},
          b: function BScreen() {},
          c: component,
          d: function DScreen() {},
        },
      },
    ];
    expect(findRouteByComponent(component, routes)).toEqual({ route: routes[1], name: 'c' });
  });
});
{'fraction_non_alphanumeric': 0.1672634271099744, 'fraction_numerical': 0.001534526854219949, 'mean_word_length': 2.739961759082218, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '512650', 'n_tokens_mistral': 536, 'n_tokens_neox': 538, 'n_words': 126}