Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit test fix #518

Merged
merged 8 commits into from
Oct 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"react-router-dom": "^5.1.2",
"react-scripts": "3.4.1",
"react-select": "^3.1.0",
"react-sortablejs": "^2.0.11",
"react-sortablejs": "2.0.11",
"react-syntax-highlighter": "^12.2.1",
"react-test-renderer": "^16.13.1",
"react-transition-group": "^4.3.0",
Expand Down
37 changes: 32 additions & 5 deletions client/src/components/Header/Header.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,40 @@
import React from 'react';
import { render } from 'enzyme';
import { TestWrapper } from '../../tests/utils';
import { TestWrapper, renderWithStore } from '../../tests/utils';
import { Header } from './Header';

jest.mock('js-cookie', () => ({
get: (key) =>
({
AUTH_USER_DATA: '{"name": "someName", "picture": "somePicture"}',
}[key]),
}));

describe('Should render header', () => {
const selectedExperimentID = '5da7cc6376e3e19307d0db64';
const header = render(
const headerProps = {
selectedExperimentID: '5da7cc6376e3e19307d0db64',
experimentDetails: {
created_by: 'dyu',
dataruns: {
id: '5f5b0df4013e4f912fba33e2',
signal: '^IXIC',
},
dataset: 'NASDAQ',
date_creation: '2020-09-11T05:41:08.221000',
id: '5f5b0df4013e4f912fba33e0',
name: 'tech2',
pipeline: 'tadgan_stock_tpl',
project: 'stock',
},
isTimeSyncEnabled: true,
experimentData: {
isExperimentDataLoading: false,
},
};

const header = renderWithStore(
{},
<TestWrapper>
<Header selectedExperimentID={selectedExperimentID} />
<Header {...headerProps} />
</TestWrapper>,
);

Expand Down
1 change: 1 addition & 0 deletions client/src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export const Header: React.FC<Props> = (props) => {
const { name, picture } = userData;
const isLinearBtnActive = currentChartStyle === 'linear' ? 'active' : '';
const isStepBtnActive = currentChartStyle !== 'linear' ? 'active' : '';

return (
<header id="header" className="main-header">
<div className="header-container">
Expand Down
51 changes: 40 additions & 11 deletions client/src/components/Header/__snapshots__/Header.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,47 @@ exports[`Should render header Renders <Header /> with enzyme 1`] = `
/>
</svg>
</a>
<ul
class="user-opts"
<div
class="header-right-wrapper"
>
<li>
<button
class="logout-button"
type="button"
>
Logout
</button>
</li>
</ul>
<ul
class="user-opts"
>
<li>
<img
alt="someName"
referrerpolicy="no-referrer"
src="somePicture"
/>
</li>
<li>
someName
</li>
<li>
<button
class="logout-button"
type="button"
>
<svg
fill="none"
height="14"
viewBox="0 0 14 14"
width="14"
>
<path
clip-rule="evenodd"
d="M5.7506 1.05448V6.32688C5.7506 6.90872 6.22324 7.38136 6.80508 7.38136C7.38692 7.38136 7.85956 6.90872 7.85956 6.32688V1.05448C7.85956 0.47264 7.38692 0 6.80508 0C6.22324 0 5.7506 0.47264 5.7506 1.05448ZM9.87444 1.6772C10.1449 1.33504 10.6433 1.27568 10.9849 1.54616C12.6212 2.83752 13.5604 4.77176 13.5604 6.8544C13.5604 10.579 10.5296 13.6097 6.80508 13.6097C3.08052 13.6097 0.0498047 10.5795 0.0498047 6.8544C0.0498047 4.77288 0.987805 2.83864 2.62356 1.54784C2.9674 1.27792 3.46412 1.33616 3.7346 1.67888C4.00508 2.02216 3.94628 2.51944 3.60356 2.78992C2.35028 3.77888 1.6318 5.26008 1.6318 6.8544C1.6318 9.70704 3.953 12.0282 6.80564 12.0282C9.65772 12.0282 11.9789 9.70704 11.9789 6.8544C11.9789 5.25952 11.2599 3.77776 10.0055 2.78824C9.66276 2.5172 9.60396 2.01992 9.87444 1.6772Z"
fill="white"
fill-rule="evenodd"
/>
</svg>
</button>
</li>
</ul>
<div
class="clear"
/>
</div>
</div>
</header>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ exports[`Testing the matrix component Should render matrix component without cra
<g>
<rect
class="bar"
fill="#FFCD00"
fill="#FF9100"
height="13"
width="0"
x="-3"
Expand All @@ -33,7 +33,7 @@ exports[`Testing the matrix component Should render matrix component without cra
<g>
<rect
class="bar"
fill="#7CA8FF"
fill="#4684FF"
height="13"
width="0"
x="-3"
Expand All @@ -47,7 +47,7 @@ exports[`Testing the matrix component Should render matrix component without cra
<g>
<rect
class="bar"
fill="#A042FF"
fill="#8446C2"
height="13"
width="0"
x="-3"
Expand All @@ -61,7 +61,7 @@ exports[`Testing the matrix component Should render matrix component without cra
<g>
<rect
class="bar"
fill="#F64242"
fill="#C24D4D"
height="13"
width="0"
x="-3"
Expand All @@ -75,7 +75,7 @@ exports[`Testing the matrix component Should render matrix component without cra
<g>
<rect
class="bar"
fill="#F5FF00"
fill="#F2FF00"
height="13"
width="0"
x="-3"
Expand All @@ -89,7 +89,7 @@ exports[`Testing the matrix component Should render matrix component without cra
<g>
<rect
class="bar"
fill="#45F642"
fill="#6BC969"
height="13"
width="0"
x="-3"
Expand All @@ -103,7 +103,7 @@ exports[`Testing the matrix component Should render matrix component without cra
<g>
<rect
class="bar"
fill="#C7C7C7"
fill="#D5D5D5"
height="13"
width="23.4375"
x="-26.4375"
Expand All @@ -116,7 +116,7 @@ exports[`Testing the matrix component Should render matrix component without cra
<path
class="bar-hat"
d="M-25.4375,86L-26.604166666666668,86C-27.770833333333332,86,-30.104166666666668,86,-31.270833333333332,88.16666666666667C-32.4375,90.33333333333333,-32.4375,94.66666666666667,-31.270833333333332,96.83333333333333C-30.104166666666668,99,-27.770833333333332,99,-26.604166666666668,99L-25.4375,99"
fill="#C7C7C7"
fill="#D5D5D5"
/>
</g>
<line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Array [
class="cell active"
>
<h3>
#1 SMAP_set1_lstm
#1
</h3>
<div
class="item-data"
Expand Down
15 changes: 15 additions & 0 deletions client/src/components/Session/Login.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import { TestWrapper, renderWithStore } from 'src/tests/utils';
import { Login } from './Login';

describe('Testing Login component ->', () => {
const LoginComponent = renderWithStore(
{},
<TestWrapper>
<Login loginStatus="unauthenticated" />
</TestWrapper>,
);
it('Should render without crashing', () => {
expect(LoginComponent).toMatchSnapshot();
});
});
3 changes: 2 additions & 1 deletion client/src/components/Session/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface LoginState {
rememberMe: boolean;
}

class Login extends Component<LoginProps, LoginState> {
export class Login extends Component<LoginProps, LoginState> {
constructor(props) {
super(props);
this.state = {
Expand Down Expand Up @@ -167,6 +167,7 @@ class Login extends Component<LoginProps, LoginState> {
color="primary"
type="button"
onClick={this.onFormSubmitHandler}
id="loginBtn"
>
{isLoading && <CircularProgress color="secondary" size={28} />}
<span>Login</span>
Expand Down
15 changes: 15 additions & 0 deletions client/src/components/Session/Register.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import { renderWithStore, TestWrapper } from 'src/tests/utils';
import { Register } from './Register';

describe('Testing Register component', () => {
const RegisterComponent = renderWithStore(
{},
<TestWrapper>
<Register />
</TestWrapper>,
);
it('Should Render witout crashing', () => {
expect(RegisterComponent).toMatchSnapshot();
});
});
2 changes: 1 addition & 1 deletion client/src/components/Session/Register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export interface RegisterProps {
};
}

class Register extends Component<RegisterProps, RegisterState> {
export class Register extends Component<RegisterProps, RegisterState> {
constructor(props) {
super(props);

Expand Down
15 changes: 15 additions & 0 deletions client/src/components/Session/ResetPassKey.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import { renderWithStore, TestWrapper } from 'src/tests/utils';
import ResetPasskey from './ResetPasskey';

describe('Testing Reset password component', () => {
const resetPassword = renderWithStore(
{},
<TestWrapper>
<ResetPasskey />
</TestWrapper>,
);
it('Should render without crashing', () => {
expect(resetPassword).toMatchSnapshot();
});
});
Loading