This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//functional testing | |
it('Renders the correct results after the search keyword is entered', () => { | |
render(<Header InitialData={SampleData}/>) | |
fireEvent.change(screen.getByTestId("searchText"), | |
{ target: { value: "2nd" } }) | |
expect(screen.getByTestId("searchText").value).toBe("2nd") | |
fireEvent.click(screen.getByRole('button')) | |
expect(screen.getAllByText(/2nd/i).length).toBe(2) | |
expect(screen.getAllByText(/1st/i).length).toBe(1) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import Header from '../components/Header' | |
import renderer from 'react-test-renderer' | |
import { render, fireEvent, screen } from '@testing-library/react' | |
const classHeader = "sample class" | |
const SampleData = new Set(["1st Sample", | |
"2nd Sample", | |
"3rd Sample"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from 'react' | |
import Search from './Search' | |
import LogoBar from './LogoBar' | |
import InitialList from './InitialList' | |
import ResultsList from './ResultsList' | |
function Header({ InitialData = new Set(["1st Option", | |
"2nd Option", | |
"3rd Option"]) }) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import Button from './Button'; | |
const defaultProps = { | |
classSearch: "", | |
title="Search", | |
searchPlaceholder:"Type here to search" | |
} | |
function Search(props =defaultProps) { |