<commit_before>import expect from 'expect'
import sinon from 'sinon'
import getRequiredKey from './get-required-key'

describe('Get required key', () => {
  const sandbox = sinon.sandbox.create()

  beforeEach(() => {
    sandbox.stub(console, 'error')
    sandbox.stub(process, 'exit')
  })

  afterEach(() => {
    sandbox.restore()
  })


  it('should fail when key is not defined', () => {
    // given
    const obj = {}
    const key = 'token'

    // then
    expect(getRequiredKey(obj, key)).toEqual(false)
  })

  it('should be token value when key is defined', () => {
    // given
    const obj = {}
    const key = 'token'
    const value = 'bar'
    obj[key] = value

    // then
    expect(getRequiredKey(obj, key)).toEqual(value)
  })

  it('should be token value when key is defined and token value is false', () => {
    // given
    const obj = {}
    const key = 'token'
    const value = false
    obj[key] = value

    // then
    expect(getRequiredKey(obj, key)).toEqual(value)
  })

  describe('Logging', () => {
    it('Should output error when key not defined', () => {
      // given
      const obj = {}
      const key = 'bar'

      // when
      getRequiredKey(obj, key)

      // then
      expect(console.error.called).toEqual(true)
    })
  })

  describe('Exiting', () => {
    it('Should not kill the process when key not defined', () => {
      // given
      const obj = {}
      const key = 'bar'
      const value = 'baz'
      obj[key] = value

      // when
      getRequiredKey(obj, key)<commit_msg>Fix typo in test spec<commit_after>import expect from 'expect'
import sinon from 'sinon'
import getRequiredKey from './get-required-key'

describe('Get required key', () => {
  const sandbox = sinon.sandbox.create()

  beforeEach(() => {
    sandbox.stub(console, 'error')
    sandbox.stub(process, 'exit')
  })

  afterEach(() => {
    sandbox.restore()
  })


  it('should fail when key is not defined', () => {
    // given
    const obj = {}
    const key = 'token'

    // then
    expect(getRequiredKey(obj, key)).toEqual(false)
  })

  it('should be token value when key is defined', () => {
    // given
    const obj = {}
    const key = 'token'
    const value = 'bar'
    obj[key] = value

    // then
    expect(getRequiredKey(obj, key)).toEqual(value)
  })

  it('should be token value when key is defined and token value is false', () => {
    // given
    const obj = {}
    const key = 'token'
    const value = false
    obj[key] = value

    // then
    expect(getRequiredKey(obj, key)).toEqual(value)
  })

  describe('Logging', () => {
    it('Should output error when key not defined', () => {
      // given
      const obj = {}
      const key = 'bar'

      // when
      getRequiredKey(obj, key)

      // then
      expect(console.error.called).toEqual(true)
    })
  })

  describe('Exiting', () => {
    it('Should not kill the process when key defined', () => {
      // given
      const obj = {}
      const key = 'bar'
      const value = 'baz'
      obj[key] = value

      // when
      getRequiredKey(obj, key)
{'fraction_non_alphanumeric': 0.15294880103694103, 'fraction_numerical': 0.0, 'mean_word_length': 2.3122317596566524, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, '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': '7221052', 'n_tokens_mistral': 985, 'n_tokens_neox': 961, 'n_words': 268}