diff --git a/client/src/components/search/searchBar/SearchBar.js b/client/src/components/search/searchBar/SearchBar.js index f83e7b650b..693e5b8cbb 100644 --- a/client/src/components/search/searchBar/SearchBar.js +++ b/client/src/components/search/searchBar/SearchBar.js @@ -45,7 +45,7 @@ const mapDispatchToProps = dispatch => const placeholder = 'Search 5,000+ tutorials'; -class SearchBar extends Component { +export class SearchBar extends Component { constructor(props) { super(props); @@ -62,8 +62,6 @@ class SearchBar extends Component { } componentDidMount() { - const searchInput = document.querySelector('.ais-SearchBox-input'); - searchInput.id = 'fcc_instantsearch'; document.addEventListener('click', this.handleFocus); } diff --git a/client/src/components/search/searchBar/SearchBar.test.js b/client/src/components/search/searchBar/SearchBar.test.js new file mode 100644 index 0000000000..4559c52fd5 --- /dev/null +++ b/client/src/components/search/searchBar/SearchBar.test.js @@ -0,0 +1,27 @@ +/* global jest, expect */ +import React from 'react'; +import 'jest-dom/extend-expect'; +import ShallowRenderer from 'react-test-renderer/shallow'; + +import { SearchBar } from './SearchBar'; + +describe('', () => { + it('renders to the DOM', () => { + const shallow = new ShallowRenderer(); + shallow.render(); + const result = shallow.getRenderOutput(); + expect(result).toBeTruthy(); + }); + + /* Todo: When e2e testing is in place, + add tests to check that the search bar + resets to -1 on change/input, redirects to a + selected hit, and redirects to dev news if + there's a query and no hit is selected */ +}); + +const searchBarProps = { + toggleSearchDropdown: jest.fn(), + toggleSearchFocused: jest.fn(), + updateSearchQuery: jest.fn() +};