initial test and 404 page
This commit is contained in:
parent
0c443a7314
commit
649cec210d
4 changed files with 45 additions and 17 deletions
|
@ -1,9 +1,10 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { Switch, Route, Redirect } from "react-router-dom";
|
import {BrowserRouter, Switch, Route, Redirect } from "react-router-dom";
|
||||||
import Home from "./views/Home";
|
import Home from "./views/Home";
|
||||||
import Dashboard from "./views/DashboardTest";
|
import Dashboard from "./views/DashboardTest";
|
||||||
import Signup from "./views/Signup";
|
import Signup from "./views/Signup";
|
||||||
import Login from "./views/Login";
|
import Login from "./views/Login";
|
||||||
|
import FourOhFour from "./views/FourOhFour";
|
||||||
import ForgotPass from "./views/Forgot-password";
|
import ForgotPass from "./views/Forgot-password";
|
||||||
import ChangePass from "./views/Forgot-pass-reset";
|
import ChangePass from "./views/Forgot-pass-reset";
|
||||||
import queryString from 'query-string';
|
import queryString from 'query-string';
|
||||||
|
@ -33,11 +34,13 @@ class App extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
if (this.props.location) {
|
||||||
const values = queryString.parse(this.props.location.search);
|
const values = queryString.parse(this.props.location.search);
|
||||||
this.setState({
|
this.setState({
|
||||||
query : values
|
query : values
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auth(data) {
|
auth(data) {
|
||||||
return call.login(data.params)
|
return call.login(data.params)
|
||||||
|
@ -77,6 +80,7 @@ class App extends React.Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
|
<BrowserRouter>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path="/" exact component={Home} />
|
<Route path="/" exact component={Home} />
|
||||||
<Route path="/login" >
|
<Route path="/login" >
|
||||||
|
@ -92,7 +96,9 @@ class App extends React.Component {
|
||||||
<Route path="/forgot-pass-reset" >
|
<Route path="/forgot-pass-reset" >
|
||||||
<ChangePass query={this.state.query}/>
|
<ChangePass query={this.state.query}/>
|
||||||
</Route>
|
</Route>
|
||||||
|
<Route component={FourOhFour} />
|
||||||
</Switch>
|
</Switch>
|
||||||
|
</BrowserRouter>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,16 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { render } from '@testing-library/react';
|
import { render } from '@testing-library/react';
|
||||||
|
import { Router } from "react-router";
|
||||||
|
import { createMemoryHistory } from "history";
|
||||||
import App from './App';
|
import App from './App';
|
||||||
|
|
||||||
test('renders learn react link', () => {
|
test("redirects to homepage", () => {
|
||||||
const { getByText } = render(<App />);
|
const history = createMemoryHistory();
|
||||||
const linkElement = getByText(/learn react/i);
|
render(
|
||||||
expect(linkElement).toBeInTheDocument();
|
<Router history={history}>
|
||||||
|
<App />
|
||||||
|
</Router>
|
||||||
|
);
|
||||||
|
expect(history.location.pathname).toBe("/");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -3,17 +3,13 @@ import ReactDOM from 'react-dom';
|
||||||
import App from './App';
|
import App from './App';
|
||||||
import * as serviceWorker from './serviceWorker';
|
import * as serviceWorker from './serviceWorker';
|
||||||
//React Router
|
//React Router
|
||||||
import { BrowserRouter, Route, Switch } from "react-router-dom";
|
//import { BrowserRouter, Route, Switch } from "react-router-dom";
|
||||||
|
|
||||||
const routes = (
|
const index = (
|
||||||
<BrowserRouter>
|
<App />
|
||||||
<Switch>
|
|
||||||
<Route path="/" component={App} />
|
|
||||||
</Switch>
|
|
||||||
</BrowserRouter>
|
|
||||||
);
|
);
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
routes
|
index
|
||||||
, document.getElementById('root'));
|
, document.getElementById('root'));
|
||||||
serviceWorker.unregister();
|
serviceWorker.unregister();
|
||||||
|
|
19
smart-hut/src/views/FourOhFour.js
Normal file
19
smart-hut/src/views/FourOhFour.js
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
import React, {Component} from 'react';
|
||||||
|
import { Message} from 'semantic-ui-react';
|
||||||
|
import {Link } from "react-router-dom";
|
||||||
|
|
||||||
|
|
||||||
|
export default class FourOhFour extends Component {
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<Message>
|
||||||
|
<Message.Header>404 Page Not Found</Message.Header>
|
||||||
|
<p>
|
||||||
|
Hey what are you doing here?
|
||||||
|
Go back to our homepage <Link to="/"/>
|
||||||
|
</p>
|
||||||
|
</Message>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue