<commit_before>/* @flow */

import test from 'ava';
import createError from './createError';

test('create function', (t) => {
  const performance = createError('performance', 'High performance');

  t.true(typeof performance === 'function');
  t.pass();
});

test('function generate an error', (t) => {
  const performance = createError('performance', 'High performance');
  const err = performance();

  t.true(err instanceof Error);
  t.pass();
});

test('generated error code', (t) => {
  const performance = createError('performance', 'High performance');
  const err = performance();

  t.is(err.code, 'performance');
  t.pass();
});

test('generated error name', (t) => {
  const performance = createError('performance', 'High performance');
  const err = performance();

  t.is(err.name, 'PerformanceError');
  t.pass();
});<commit_msg>Improve createError tests<commit_after>/* @flow */

import test from 'ava';
import createError from './createError';

test('return function', (t) => {
  const performance = createError('performance', 'High performance');

  t.true(typeof performance === 'function');
  t.pass();
});

test('returned function generates an error', (t) => {
  const performance = createError('performance', 'High performance');
  const err = performance();

  t.true(err instanceof Error);
  t.pass();
});

test('returned function generates an error with correct message', (t) => {
  const performance = createError('performance', 'High performance');
  const err = performance();

  t.is(err.message, 'High performance');
  t.pass();
});

test('returned function generates an error with correct code', (t) => {
  const performance = createError('performance', 'High performance');
  const err = performance();

  t.is(err.code, 'performance');
  t.pass();
});

test('returned function generates an error with correct name', (t) => {
  const performance = createError('performance', 'High performance');
  const err = performance();

  t.is(err.name, 'PerformanceError');
  t.pass();
});
{'fraction_non_alphanumeric': 0.17454002983590253, 'fraction_numerical': 0.0, 'mean_word_length': 4.970326409495549, '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': '6402693', 'n_tokens_mistral': 582, 'n_tokens_neox': 558, 'n_words': 172}