<commit_before><commit_msg>Add CatalogPreview test<commit_after>import React from 'react'
import { shallow } from 'enzyme'
import CatalogPreview from '../CatalogPreview'
import Percent from '../../../Statistics/Percent/Percent'
import Counter from '../../../Statistics/Counter/Counter'

import metrics from '../../../fetch/__test__/metrics.json'

describe('<CatalogPreviewPreview />', () => {
  const styles = {
    stat: {
      margin: '2em',
    }
  }

  describe('metrics is defined', () => {
    let wrapper
    beforeEach(() =>  {
      wrapper = shallow(<CatalogPreview metrics={metrics} />)
    })

    it('should display the number of records', () => {
      const records = <Counter style={styles.stat} value={metrics.totalCount} size="small" label="Records" />

      expect(wrapper.contains(records)).toBe(true)
    })

    it('should display the openness percent', () => {
      const open = <Percent style={styles.stat} value={ metrics.partitions['openness'].yes} total={metrics.totalCount} label="open data" icon="unlock alternate icon" size="small" />

      expect(wrapper.contains(open)).toBe(true)
    })

    it('should display the downloadable percent', () => {
      const download = <Percent style={styles.stat} value={ metrics.partitions['download'].yes} total={metrics.totalCount} label="downloadable" icon="download" size="small" />

      expect(wrapper.contains(download)).toBe(true)
    })
  })

  describe('metrics is undefined', () => {
    let wrapper
    beforeEach(() =>  {
      wrapper = shallow(<CatalogPreview metrics={undefined} />)
    })

    it('should render an empty div', () => {
      expect(wrapper.html()).toEqual('<div></div>')
    })
  })

})
{'fraction_non_alphanumeric': 0.17612293144208038, 'fraction_numerical': 0.000591016548463357, 'mean_word_length': 3.5880758807588076, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6538560', 'n_tokens_mistral': 473, 'n_tokens_neox': 462, 'n_words': 105}