<commit_before>import React from "react";
import createIsSpecificShallowEqual from "../createSpecificShallowEqual";
import {Map, List} from "immutable";

const keysToTest = ["name", "required", "inputInfo", "children"];

const currentProps = {
  name: "Shane",
  required: true,
  inputInfo: Map({
    value: '1',
    blurred: true
  })
};

const nextPropsFailBool = {
  name: "Shane",
  required: false,
  inputInfo: Map({
    value: '1',
    blurred: true
  })
};

const nextPropsFailString = {
  name: "Peter",
  required: true,
  inputInfo: Map({
    value: '1',
    blurred: true
  })
};

const nextPropsFailImmut = {
  name: "Peter",
  required: true,
  inputInfo: Map({
    value: '1',
    blured: true
  })
};

const currentPropsNan = {
  name: NaN,
}

const currentPropsObj = {
  name: {},
}

const currentPropsDom = {
  children: List([<span></span>]),
  required: true,
  inputInfo: Map({
    value: '1',
    blurred: true
  })
};

const nextPropsDom = {
  children: List([<span>label</span>]),
  required: true,
  inputInfo: Map({
    value: '1',
    blurred: true
  })
};


describe('createIsSpecificShallowEqual()', () => {
  const isSpecificShallowEqual = createIsSpecificShallowEqual(...keysToTest);
  it('returns a function', () => {
    expect(isSpecificShallowEqual).toBeInstanceOf(Function);
  });
  describe('isSpecificShallowEqual()', () => {
    it('compares identical objects', () => {
      expect(isSpecificShallowEqual(currentProps, currentProps)).toBe(true);
    });
    it('compares different objects: bool is different', () => {
      expect(isSpecificShallowEqual(currentProps, nextPropsFailBool)).toBe(false);
    });
    it('compares different objects: string is different', () => {
      expect(isSpecificShallowEqual(currentProps, nextPropsFailString)).toBe(false);
    });
    it('compares different DOM nodes: child is different', () => {
      expect(isSpecificShallowEqual(currentPropsDom, nextPropsDom)).toBe(false);
    });
    it('compares throwing objects: NaN doesn\'t throw', () => {
      expect(() => isSpecificShallowEqual(currentPropsNan, currentPropsNan)).toThrowError();
    });
    it('compares throwing objects: object doesn\'t throw', () => {
      expect(() => isSpecificShallowEqual(currentPropsObj, currentPropsObj)).toThrowError();
    });
  });
});<commit_msg>added truth test<commit_after>import React from "react";
import createIsSpecificShallowEqual from "../createSpecificShallowEqual";
import {Map, List} from "immutable";

const keysToTest = ["name", "required", "inputInfo", "children"];

const currentProps = {
  name: "Shane",
  required: true,
  inputInfo: Map({
    value: '1',
    blurred: true
  })
};

const nextPropsFailBool = {
  name: "Shane",
  required: false,
  inputInfo: Map({
    value: '1',
    blurred: true
  })
};

const nextPropsFailString = {
  name: "Peter",
  required: true,
  inputInfo: Map({
    value: '1',
    blurred: true
  })
};

const nextPropsFailImmut = {
  name: "Peter",
  required: true,
  inputInfo: Map({
    value: '1',
    blured: true
  })
};

const currentPropsNan = {
  name: NaN,
}

const currentPropsObj = {
  name: {},
}

const currentPropsDom = {
  children: List([<span></span>]),
  required: true,
  inputInfo: Map({
    value: '1',
    blurred: true
  })
};

const nextPropsDom = {
  children: List([<span>label</span>]),
  required: true,
  inputInfo: Map({
    value: '1',
    blurred: true
  })
};


describe('createIsSpecificShallowEqual()', () => {
  const isSpecificShallowEqual = createIsSpecificShallowEqual(...keysToTest);
  it('returns a function', () => {
    expect(isSpecificShallowEqual).toBeInstanceOf(Function);
  });
  describe('isSpecificShallowEqual()', () => {
    it('compares identical objects', () => {
      expect(isSpecificShallowEqual(currentProps, currentProps)).toBe(true);
    });
    it('compares different objects: bool is different', () => {
      expect(isSpecificShallowEqual(currentProps, nextPropsFailBool)).toBe(false);
    });
    it('compares different objects: string is different', () => {
      expect(isSpecificShallowEqual(currentProps, nextPropsFailString)).toBe(false);
    });
    it('compares different DOM nodes: child is different', () => {
      expect(isSpecificShallowEqual(currentPropsDom, nextPropsDom)).toBe(false);
    });
    it('compares identical child objects', () => {
      expect(isSpecificShallowEqual(currentPropsDom, currentPropsDom)).toBe(true);
    });
    it('compares throwing objects: NaN doesn\'t throw', () => {
      expect(() => isSpecificShallowEqual(currentPropsNan, currentPropsNan)).toThrowError();
    });
    it('compares throwing objects: object doesn\'t throw', () => {
      expect(() => isSpecificShallowEqual(currentPropsObj, currentPropsObj)).toThrowError();
    });
  });
});
{'fraction_non_alphanumeric': 0.16119590215346016, 'fraction_numerical': 0.0025088856366297305, 'mean_word_length': 4.144086021505377, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 34, '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': '2268582', 'n_tokens_mistral': 1522, 'n_tokens_neox': 1478, 'n_words': 318}