<commit_before>import React from 'react'
import ReactDOM from 'react-dom'
import Parcel from './parcel.js'
import {mount} from 'enzyme'
import {SingleSpaContext} from '../lib/single-spa-react.js'

document.body.appendChild = jest.fn()

describe(`<Parcel />`, () => {
  let config, mountParcel = jest.fn(), parcel, props

  beforeEach(() => {
    config = {
      bootstrap: jest.fn(),
      mount: jest.fn(),
      unmount: jest.fn(),
    }

    parcel = {
      loadPromise: jest.fn(),
      bootstrapPromise: jest.fn(),
      mountPromise: jest.fn(),
      unmountPromise: jest.fn(),
      getStatus: jest.fn(),
      unmount: jest.fn(),
      update: jest.fn(),
    }

    mountParcel.mockReset()
    mountParcel.mockReturnValue(parcel)

    document.body.appendChild.mockReset()

    props = {mountParcel, config}
  })

  it(`throws an error if you try to render the component without a config`, () => {
    expect(() => {
      shallow(<Parcel />)
    }).toThrow()
  })

  it(`renders a div by default`, () => {
    const wrapper = mount(<Parcel {...props} />)
    expect(wrapper.find('div').length).toBe(1)
  })

  it(`calls the mountParcel prop when it mounts`, () => {
    const wrapper = mount(<Parcel {...props} />)
    return wrapper.instance().nextThingToDo.then(() => {
      expect(mountParcel).toHaveBeenCalled()
    })
  })

  it(`renders nothing if you pass in the appendTo prop`, () => {
    const wrapper = mount(<Parcel {...props} appendTo={document.body} />)
    return wrapper.instance().nextThingToDo.then(() => {
      expect(document.body.appendChild).toHaveBeenCalled()
    })
  })
<commit_msg>Fixing tests and adding one for parcelWasMounted prop<commit_after>import React from 'react'
import ReactDOM from 'react-dom'
import Parcel from './parcel.js'
import {mount} from 'enzyme'
import {SingleSpaContext} from '../lib/single-spa-react.js'

document.body.appendChild = jest.fn()

describe(`<Parcel />`, () => {
  let config, mountParcel = jest.fn(), parcel, props

  beforeEach(() => {
    config = {
      bootstrap: jest.fn(),
      mount: jest.fn(),
      unmount: jest.fn(),
    }

    parcel = {
      loadPromise: jest.fn(),
      bootstrapPromise: jest.fn(),
      mountPromise: Promise.resolve(),
      unmountPromise: jest.fn(),
      getStatus: jest.fn(),
      unmount: jest.fn(),
      update: jest.fn(),
    }

    mountParcel.mockReset()
    mountParcel.mockReturnValue(parcel)

    document.body.appendChild.mockReset()

    props = {mountParcel, config}
  })

  it(`throws an error if you try to render the component without a config`, () => {
    expect(() => {
      shallow(<Parcel />)
    }).toThrow()
  })

  it(`renders a div by default`, () => {
    const wrapper = mount(<Parcel {...props} />)
    expect(wrapper.find('div').length).toBe(1)
  })

  it(`calls the mountParcel prop when it mounts`, () => {
    const wrapper = mount(<Parcel {...props} />)
    return wrapper.instance().nextThingToDo.then(() => {
      expect(mountParcel).toHaveBeenCalled()
    })
  })

  it(`renders nothing if you pass in the appendTo prop`, () => {
    const wrapper = mount(<Parcel {...props} appendTo={document.body} />)
    return wrapper.instance().nextThingToDo.then(() => {
      expect(document.body.appendChild).toHaveBeenCalled()
    })
  })

  it(`calls parcelWasMounted prop when the parcel finishes mounting`, () => {
    const parcelWasMounted = jest.fn()
    const wrapper = mount(<Parcel {...props} parcelWasMounted={parcelWasMounted} />)

    expect(parcelWasMounted).not.toHaveBeenCalled()

    return wrapper.instance().nextThingToDo.then(() => {
      expect(parcelWasMounted).toHaveBeenCalled()
    })
  })

{'fraction_non_alphanumeric': 0.1662117903930131, 'fraction_numerical': 0.0005458515283842794, 'mean_word_length': 3.1179775280898876, 'pattern_counts': {'":': 0, '<': 14, '<?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': '4849111', 'n_tokens_mistral': 1181, 'n_tokens_neox': 1142, 'n_words': 257}