-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-creation of custom error page [Finishes #165244211]
- Loading branch information
1 parent
0394c0c
commit 33f612d
Showing
10 changed files
with
222 additions
and
20,903 deletions.
There are no files selected for viewing
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from 'react'; | ||
import { Button } from 'react-bootstrap'; | ||
import PropTypes from 'prop-types'; | ||
import { withRouter } from 'react-router-dom'; | ||
|
||
function PageNotFound(props) { | ||
const { push } = props.history; | ||
return ( | ||
<section className="page_404"> | ||
<div className="container"> | ||
<div className="four_zero_four_bg"> | ||
<h1 className="text-center ">404</h1> | ||
</div> | ||
|
||
<div className="contant_box_404"> | ||
<h3 className="h2">Looks like you are lost</h3> | ||
|
||
<p>We dont have the page you are looking for</p> | ||
<Button | ||
className="btn-one" | ||
onClick={() => { | ||
push('/'); | ||
}} | ||
> | ||
Go home | ||
</Button> | ||
</div> | ||
</div> | ||
</section> | ||
); | ||
} | ||
PageNotFound.propTypes = { | ||
history : PropTypes.object, | ||
}; | ||
|
||
export default PageNotFound; |
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 |
---|---|---|
@@ -1,12 +1,11 @@ | ||
const initialState = { | ||
articles: [], | ||
notifications: [], | ||
followers: [], | ||
} | ||
|
||
function rootReducer(state = initialState, action){ | ||
|
||
return state; | ||
articles: [], | ||
notifications: [], | ||
followers: [], | ||
}; | ||
|
||
function rootReducer(state = initialState) { | ||
return state; | ||
} | ||
|
||
export default rootReducer; |
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,5 @@ | ||
import React from 'react'; | ||
const rrd = require('react-router-dom'); | ||
// Just render plain div with its children | ||
rrd.BrowserRouter = ({children}) => <div>{children}</div> | ||
module.exports = rrd; |
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,51 @@ | ||
|
||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { mount } from 'enzyme'; | ||
import { MemoryRouter } from 'react-router'; | ||
import Home from '../../components/Home'; | ||
import PageNotFound from '../../components/404'; | ||
import Routes from '../../routes/index'; | ||
|
||
jest.mock("react-router-dom/BrowserRouter", () => { | ||
return ({ children }) => <div>{children}</div>; | ||
}); | ||
|
||
test('invalid path should redirect to 404', () => { | ||
const wrapper = mount( | ||
<MemoryRouter initialEntries={[ '/hfwyrefgwefuwejhfbjew' ]}> | ||
<Routes/> | ||
</MemoryRouter> | ||
); | ||
expect(wrapper.find(PageNotFound)).toHaveLength(1); | ||
}); | ||
|
||
test('user is redirected to homepage after clicking on the button', () => { | ||
const wrapper = mount( | ||
<MemoryRouter initialEntries={[ '/' ]}> | ||
<Routes/> | ||
</MemoryRouter> | ||
); | ||
const props = { | ||
history : { | ||
push : jest.fn() | ||
} | ||
} | ||
const component = mount(<PageNotFound {...props}/>); | ||
console.log(component.props) | ||
component | ||
.find('button') | ||
.simulate('click'); | ||
|
||
|
||
expect(wrapper.find(Home)).toHaveLength(1); | ||
}); | ||
|
||
test('valid path should not redirect to 404', () => { | ||
const wrapper = mount( | ||
<MemoryRouter initialEntries={[ '/' ]}> | ||
<Routes/> | ||
</MemoryRouter> | ||
); | ||
expect(wrapper.find(Home)).toHaveLength(1); | ||
}); |