<commit_before>import { is, DataType, isOptions } from '../is.func';
import { matchesSchema } from '../is.internal';
import * as TC from './test-cases/test-cases.spec';

describe('`is` and `matchesSchema`', () => {

  it('should validate for invalid `type` arguments', () => {
    expect( () => is(false, -1) ).toThrow();
  });

  describe('for `number` types', () => {
    const currentDataType = DataType.number;

    it('should work in regular use cases', () => {
      TC.validNumberUseCases
        .forEach( n =>
          expect( is(n, currentDataType) && matchesSchema(n, { type: currentDataType }) )
            .toBe(true, `Failed for valid \`${DataType[currentDataType]}\` use case ${n}`) );
      TC.validNumberNegativeUseCases
        .forEach( n =>
          expect( is(n, currentDataType) && matchesSchema(n, { type: currentDataType }) )
            .toBe(true, `Failed for valid negative \`${DataType[currentDataType]}\` use case ${n}`) );
      TC.invalidNumberUseCases
        .forEach( n =>
          expect( is(n, currentDataType) && matchesSchema(n, { type: currentDataType }) )
            .toBe(false, `Failed for invalid \`${DataType[currentDataType]}\` use case ${n}`) );
    });

    it('should work in optional use cases', () => {
      TC.numberRangeUseCases
        .forEach( n =>
          expect( is(n.test, currentDataType, n.options ) && matchesSchema(n.test, { type: currentDataType, options: n.options }) )
            .toBe(n.expect, `Failed for \`${DataType[currentDataType]}\` range options use case ${n.test} with options ${JSON.stringify(n.options)}`) );
      TC.multipleOfUseCases
        .forEach( n =>
          expect( is(n.test, currentDataType, n.options ) && matchesSchema(n.test, { type: currentDataType, options: n.options }) )<commit_msg>test(is): add test to ensure coverage around `type` on `is`<commit_after>import { is, DataType, isOptions } from '../is.func';
import { matchesSchema } from '../is.internal';
import * as TC from './test-cases/test-cases.spec';

describe('`is` and `matchesSchema`', () => {

  it('should validate for invalid `type` arguments', () => {
    expect( () => is(false, -1) ).toThrow();
    expect( () => is(false, DataType[1] as any) ).toThrow();
    expect( () => is(false, 1) ).not.toThrow();
  });

  describe('for `number` types', () => {
    const currentDataType = DataType.number;

    it('should work in regular use cases', () => {
      TC.validNumberUseCases
        .forEach( n =>
          expect( is(n, currentDataType) && matchesSchema(n, { type: currentDataType }) )
            .toBe(true, `Failed for valid \`${DataType[currentDataType]}\` use case ${n}`) );
      TC.validNumberNegativeUseCases
        .forEach( n =>
          expect( is(n, currentDataType) && matchesSchema(n, { type: currentDataType }) )
            .toBe(true, `Failed for valid negative \`${DataType[currentDataType]}\` use case ${n}`) );
      TC.invalidNumberUseCases
        .forEach( n =>
          expect( is(n, currentDataType) && matchesSchema(n, { type: currentDataType }) )
            .toBe(false, `Failed for invalid \`${DataType[currentDataType]}\` use case ${n}`) );
    });

    it('should work in optional use cases', () => {
      TC.numberRangeUseCases
        .forEach( n =>
          expect( is(n.test, currentDataType, n.options ) && matchesSchema(n.test, { type: currentDataType, options: n.options }) )
            .toBe(n.expect, `Failed for \`${DataType[currentDataType]}\` range options use case ${n.test} with options ${JSON.stringify(n.options)}`) );
      TC.multipleOfUseCases
        .forEach( n =>
          expect( is(n.test, currentDataType, n.options ) && matchesSchema(n.test, { type: currentDataType, options: n.options }) )
{'fraction_non_alphanumeric': 0.1714438789177605, 'fraction_numerical': 0.0010715242432360033, 'mean_word_length': 3.0898138006571743, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5858915', 'n_tokens_mistral': 1118, 'n_tokens_neox': 1122, 'n_words': 287}