This repository has been archived by the owner on Sep 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
240 additions
and
10 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react' | ||
import renderer from 'react-test-renderer' | ||
import Enzyme from 'enzyme' | ||
import { shallow } from 'enzyme' | ||
import Adapter from 'enzyme-adapter-react-16' | ||
|
||
import SearchExamples from '../src/SearchExamples' | ||
|
||
import searchExamples from './utils/searchExamples' | ||
|
||
Enzyme.configure({ adapter: new Adapter() }) | ||
|
||
const props = { | ||
links: searchExamples.filter(() => Math.random() > 0.5) | ||
} | ||
|
||
describe(`SearchExamples`, () => { | ||
test(`renders one link per element`, () => { | ||
const wrapper = shallow(<SearchExamples {...props} />) | ||
expect(wrapper.find(`a`)).toHaveLength(props.links.length) | ||
}) | ||
|
||
test(`matches snapshot`, () => { | ||
const tree = | ||
renderer | ||
.create(<SearchExamples links={searchExamples} />) | ||
.toJSON() | ||
expect(tree).toMatchSnapshot() | ||
}) | ||
}) |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`SearchExamples matches snapshot 1`] = ` | ||
<p | ||
style={ | ||
Object { | ||
"fontSize": "smaller", | ||
} | ||
} | ||
> | ||
Examples: | ||
<span> | ||
<a | ||
href="http://rickandmorty.wikia.com/wiki/Special:Search?query=Rick+Sanchez" | ||
> | ||
Rick Sanchez | ||
</a> | ||
, | ||
</span> | ||
<span> | ||
<a | ||
href="http://rickandmorty.wikia.com/wiki/Special:Search?query=Unity" | ||
> | ||
Unity | ||
</a> | ||
, | ||
</span> | ||
<span> | ||
<a | ||
href="http://rickandmorty.wikia.com/wiki/Special:Search?query=Galactic+Federation" | ||
> | ||
Galactic Federation | ||
</a> | ||
, | ||
</span> | ||
<span> | ||
<a | ||
href="http://rickandmorty.wikia.com/wiki/Special:Search?query=Blemflarck" | ||
> | ||
Blemflarck | ||
</a> | ||
, | ||
</span> | ||
<span> | ||
<a | ||
href="http://rickandmorty.wikia.com/wiki/Special:Search?query=anatomy" | ||
> | ||
anatomy | ||
</a> | ||
</span> | ||
</p> | ||
`; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const searchExamples = [ | ||
{ | ||
text: `Rick Sanchez`, | ||
url: `http://rickandmorty.wikia.com/wiki/Special:Search?query=Rick+Sanchez` | ||
}, | ||
{ | ||
text: `Unity`, | ||
url: `http://rickandmorty.wikia.com/wiki/Special:Search?query=Unity` | ||
}, | ||
{ | ||
text: `Galactic Federation`, | ||
url: `http://rickandmorty.wikia.com/wiki/Special:Search?query=Galactic+Federation` | ||
}, | ||
{ | ||
text: `Blemflarck`, | ||
url: `http://rickandmorty.wikia.com/wiki/Special:Search?query=Blemflarck` | ||
}, | ||
{ | ||
text: `anatomy`, | ||
url: `http://rickandmorty.wikia.com/wiki/Special:Search?query=anatomy` | ||
} | ||
] | ||
|
||
export default searchExamples |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
|
||
const SearchExamples = ({links}) => | ||
<p style={{fontSize: `smaller`}}>Examples: | ||
{ | ||
links.map( | ||
(link, index) => | ||
<span key={index}> | ||
{index === 0 && ` `}<a href={link.url}>{link.text}</a>{index < links.length - 1 && `, `} | ||
</span>) | ||
} | ||
</p> | ||
|
||
SearchExamples.propTypes = { | ||
links: PropTypes.arrayOf(PropTypes.shape({ | ||
text: PropTypes.string.isRequired, | ||
url: PropTypes.string.isRequired | ||
})).isRequired | ||
} | ||
|
||
export default SearchExamples |