<commit_before>import React from 'react';
import ReactDOM from 'react-dom';
import App from '../App';
import { testBooks, jsonHeaders } from '../../testData'

it('renders without crashing', () => {
  fetch.mockResponse(JSON.stringify(testBooks), { jsonHeaders });

  const div = document.createElement('div');
  ReactDOM.render(<App />, div);
});<commit_msg>expand tests for App<commit_after>import React from 'react';
import ReactDOM from 'react-dom';
import { Sidebar } from 'semantic-ui-react'
import { mount } from 'enzyme'

import App from '../App';
import Shelf from '../Shelf'
import TopBar from '../TopBar'
import { testBooks, jsonHeaders } from '../../testData'

describe('App', () => {
  let wrapper;

  beforeAll(() => {
    fetch.mockResponse(JSON.stringify(testBooks), { jsonHeaders });
    wrapper = mount(<App />)
  })
  
  it('renders without crashing', () => {
    fetch.mockResponse(JSON.stringify(testBooks), { jsonHeaders });

    const div = document.createElement('div');
    ReactDOM.render(<App />, div);
  });

  it('renders the correct number of shelves', () => {
    expect(wrapper.find(Shelf).length).toBe(2)
  })

  it('renders a TopBar', () => {
    expect(wrapper.find(TopBar).length).toBe(1)
  })

  it('renders a toggleable Sidebar', () => {
    expect(wrapper.find(Sidebar).length).toBe(1)
  })

  it('shows and hides the sidebar', () => {
    expect(wrapper.state('menuVisible')).toBe(false)
    wrapper.instance().toggleMenu()
    expect(wrapper.state('menuVisible')).toBe(true)
    wrapper.instance().toggleMenu()
    expect(wrapper.state('menuVisible')).toBe(false)
  })

  it('updates the query', () => {
    const testQuery = "test"

    expect(wrapper.state('filterQuery')).toBe('')
    wrapper.instance().updateQuery(testQuery)
    expect(wrapper.state('filterQuery')).toBe(testQuery)
  })

  it('clears the query', () => {
    const testQuery = "test"

    wrapper.instance().updateQuery(testQuery)
    expect(wrapper.state('filterQuery')).toBe(testQuery)
    wrapper.instance().clearQuery()
    expect(wrapper.state('filterQuery')).toBe('')
  })
})
{'fraction_non_alphanumeric': 0.1849904397705545, 'fraction_numerical': 0.0014340344168260039, 'mean_word_length': 4.167901234567902, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 16, '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': '3382114', 'n_tokens_mistral': 654, 'n_tokens_neox': 637, 'n_words': 126}