<commit_before>/* eslint-env jest */

import React from 'react'
import {
  shallow
} from 'enzyme'

const getMockProps = () => ({
  result: {
    title: 'Some search result',
    linkURL: 'http://www.example.com',
    snippet: 'This is the search result description.'
  }
})

afterEach(() => {
  jest.clearAllMocks()
})

describe('SearchTextResult page component', () => {
  it('renders without error', () => {
    const SearchTextResult = require('js/components/Search/SearchTextResult').default
    const mockProps = getMockProps()
    shallow(
      <SearchTextResult {...mockProps} />
    )
  })
})<commit_msg>Add more tests<commit_after>/* eslint-env jest */

import React from 'react'
import {
  shallow
} from 'enzyme'

const getMockProps = () => ({
  result: {
    title: 'Some search result',
    linkURL: 'http://www.example.com',
    snippet: 'This is the search result description.'
  }
})

afterEach(() => {
  jest.clearAllMocks()
})

describe('SearchTextResult page component', () => {
  it('renders without error', () => {
    const SearchTextResult = require('js/components/Search/SearchTextResult').default
    const mockProps = getMockProps()
    shallow(
      <SearchTextResult {...mockProps} />
    )
  })

  it('displays the title as a clickable link', () => {
    const SearchTextResult = require('js/components/Search/SearchTextResult').default
    const mockProps = getMockProps()
    mockProps.result.title = 'Hey, click to our site!'
    const wrapper = shallow(
      <SearchTextResult {...mockProps} />
    )
    const anchor = wrapper.find(`a[href="${mockProps.result.linkURL}"]`).first()
    expect(anchor.find('h3').first().text()).toEqual('Hey, click to our site!')
  })

  it('displays the link URL', () => {
    const SearchTextResult = require('js/components/Search/SearchTextResult').default
    const mockProps = getMockProps()
    mockProps.result.linkURL = 'https://example.io'
    const wrapper = shallow(
      <SearchTextResult {...mockProps} />
    )
    const linkURL = wrapper
      .find('div')
      .filterWhere(n => n.text() === 'https://example.io')
    expect(linkURL.length).toBe(1)
  })

  it('displays the snippet text', () => {
    const SearchTextResult = require('js/components/Search/SearchTextResult').default
    const mockProps = getMockProps()
    mockProps.result.snippet = 'Hi there!'
    const wrapper = shallow(
      <SearchTextResult {...mockProps} />
    )
    const snippetElem = wrapper
      .find('div')
      .filterWhere(n => n.text() === 'Hi there!')
    expect(snippetElem.length).toBe(1)
  })
})
{'fraction_non_alphanumeric': 0.16083916083916083, 'fraction_numerical': 0.0011655011655011655, 'mean_word_length': 3.371816638370119, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 21, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '2560368', 'n_tokens_mistral': 791, 'n_tokens_neox': 783, 'n_words': 174}