<commit_before>import _ from 'lodash'
import getUnhandledProps from '../../../src/utils/getUnhandledProps'

// Helper class that takes in props and merges defaultProps
class TestClass {
  constructor(props) {
    this.props = _.assign({}, this.constructor.defaultProps, props)
    this.unhandledProps = getUnhandledProps(this)
  }
}

describe('getUnhandledProps', () => {
  it('removes props defined in propTypes', () => {
    TestClass.propTypes = { removeMe: 'thanks' }
    new TestClass()
      .unhandledProps
      .should.not.have.any.keys(_.keys(TestClass.propTypes))
  })
  it('leaves props if not defined in propTypes', () => {
    const userProps = { leaveThis: 'because it is unhandled' }
    TestClass.propTypes = { removeMe: 'because we are handling it' }
    const unhandled = new TestClass(userProps).unhandledProps

    unhandled.should.not.have.any.keys(_.keys(TestClass.propTypes))
    unhandled.should.have.all.keys(_.keys(userProps))
  })
  it('leaves propType props if also defined in defaultProps', () => {
    TestClass.propTypes = { leaveMe: 'because it is also in defaultProps' }
    TestClass.defaultProps = { leaveMe: 'here i am' }
    const unhandled = new TestClass().unhandledProps

    unhandled.should.have.all.keys(_.keys(TestClass.defaultProps))<commit_msg>refactor(getUnhandledPops-test): remove lodash dep<commit_after>import getUnhandledProps from '../../../src/utils/getUnhandledProps'

// Helper class that takes in props and merges defaultProps
class TestClass {
  constructor(props) {
    this.props = { ...this.constructor.defaultProps, ...props }
    this.unhandledProps = getUnhandledProps(this)
  }
}

describe('getUnhandledProps', () => {
  it('removes props defined in propTypes', () => {
    TestClass.propTypes = { removeMe: 'thanks' }
    new TestClass()
      .unhandledProps
      .should.not.have.any.keys(Object.keys(TestClass.propTypes))
  })
  it('leaves props if not defined in propTypes', () => {
    const userProps = { leaveThis: 'because it is unhandled' }
    TestClass.propTypes = { removeMe: 'because we are handling it' }
    const unhandled = new TestClass(userProps).unhandledProps

    unhandled.should.not.have.any.keys(Object.keys(TestClass.propTypes))
    unhandled.should.have.all.keys(Object.keys(userProps))
  })
  it('leaves propType props if also defined in defaultProps', () => {
    TestClass.propTypes = { leaveMe: 'because it is also in defaultProps' }
    TestClass.defaultProps = { leaveMe: 'here i am' }
    const unhandled = new TestClass().unhandledProps

    unhandled.should.have.all.keys(Object.keys(TestClass.defaultProps))
{'fraction_non_alphanumeric': 0.12940275650842267, 'fraction_numerical': 0.0, 'mean_word_length': 3.939508506616257, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '6070563', 'n_tokens_mistral': 828, 'n_tokens_neox': 820, 'n_words': 180}