Skip to content

Commit

Permalink
Fix tests for auth components
Browse files Browse the repository at this point in the history
  • Loading branch information
amalv committed Feb 15, 2019
1 parent 43fe877 commit 1c5c343
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 39 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
language: node_js
node_js:
- "10.0"
before_script:
- yarn linter
script:
- yarn build
after_script:
- yarn linter
- yarn coveralls
after_success:
- yarn lh --perf=90 https://loving-golick-23af51.netlify.com
Expand Down
3 changes: 2 additions & 1 deletion src/components/SignIn/SignIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ class SignIn extends React.Component<Props, State> {
}
}

export const StyledSignIn = withTheme()(SignIn);
export default connect(
null,
null
)(withTheme()(SignIn));
)(withTheme()(StyledSignIn));
1 change: 1 addition & 0 deletions src/components/SignIn/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import SignIn from "./SignIn";

export { StyledSignIn } from "./SignIn";
export default SignIn;
3 changes: 2 additions & 1 deletion src/components/SignUp/SignUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ class SignUp extends React.Component<Props, State> {
}
}

export const StyledSignUp = withTheme()(SignUp);
export default connect(
null,
null
)(withTheme()(SignUp));
)(withTheme()(StyledSignUp));
1 change: 1 addition & 0 deletions src/components/SignUp/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import SignUp from "./SignUp";

export { StyledSignUp } from "./SignUp";
export default SignUp;
19 changes: 2 additions & 17 deletions src/components/__tests__/SignIn.test.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
import React from "react";
import { render, waitForElement } from "react-testing-library";
import { Router } from "react-router-dom";
import { createMemoryHistory } from "history";
import SignIn from "../SignIn";

const renderWithRouter = (
ui,
{
route = "/",
history = createMemoryHistory({ initialEntries: [route] }),
} = {}
) => ({
...render(<Router history={history}>{ui}</Router>),
history,
});

const renderComponent = () => renderWithRouter(<SignIn />);
import { StyledSignIn } from "../SignIn";

describe("Test SignIn", () => {
test("it renders sign in text", async () => {
const { getByText } = renderComponent();
const { getByText } = render(<StyledSignIn />);
await waitForElement(() => getByText(/Sign in/i));
});
});
21 changes: 3 additions & 18 deletions src/components/__tests__/SignUp.test.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
import React from "react";
import { render, waitForElement } from "react-testing-library";
import { Router } from "react-router-dom";
import { createMemoryHistory } from "history";
import SignUp from "../SignUp";

const renderWithRouter = (
ui,
{
route = "/",
history = createMemoryHistory({ initialEntries: [route] }),
} = {}
) => ({
...render(<Router history={history}>{ui}</Router>),
history,
});

const renderComponent = () => renderWithRouter(<SignUp />);
import { StyledSignUp } from "../SignUp/SignUp";

describe("Test SignUp", () => {
test("it renders Sign up text", async () => {
const { getByText } = renderComponent();
test("it renders sign up text", async () => {
const { getByText } = render(<StyledSignUp />);
await waitForElement(() => getByText(/Sign up/i));
});
});

0 comments on commit 1c5c343

Please sign in to comment.