Skip to content

Commit

Permalink
✅ Fix failing Search test
Browse files Browse the repository at this point in the history
  • Loading branch information
macdonst committed Dec 16, 2020
1 parent 1204a65 commit c3b242a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
18 changes: 3 additions & 15 deletions src/Search/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const Search = ({
sections,
searchCallback,
placeholder = 'Search…',
width = 'size-4600'
width = 'size-4600',
...props
}) => {
const searchRef = useRef(null)
const searchField = useRef(null)
Expand All @@ -48,20 +49,6 @@ const Search = ({
search(query)
}, [query])

/*
const search = (searchTerm) => {
const searchResults = index
.search(searchTerm, { expand: true })
.map(({ ref }) => {
return index.documentStore.getDoc(ref)
})
setResults(searchResults)
if (searchTerm.length > 0) setIsOpen(true)
}
*/

const search = async (searchTerm) => {
if (searchTerm.length > 0) {
const searchResults = await searchCallback(searchTerm)
Expand Down Expand Up @@ -103,6 +90,7 @@ const Search = ({
style={{
position: 'relative'
}}
{...props}
>
<SearchField
ref={searchField}
Expand Down
8 changes: 1 addition & 7 deletions src/Search/test/Search.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,9 @@ import React from 'react'
import { render } from 'test-utils'
import { Search } from '../index'

const elasticlunr = require(`elasticlunr`)

const index = elasticlunr()

describe('<Search />', () => {
test('should render', () => {
const { getByTestId } = render(
<Search searchIndex={index.toJSON()} data-testid='el' />
)
const { getByTestId } = render(<Search data-testid='el' />)
const el = getByTestId('el')

expect(el).toBeInTheDocument()
Expand Down

0 comments on commit c3b242a

Please sign in to comment.