Skip to content
This repository has been archived by the owner on Oct 1, 2019. It is now read-only.

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
artkravchenko committed Jul 5, 2017
1 parent 658931e commit 54d66bd
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 8 deletions.
10 changes: 9 additions & 1 deletion src/pages/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import React, { PropTypes } from 'react';
import ga from 'react-google-analytics';
import Helmet from 'react-helmet';
import { connect } from 'react-redux';
import noop from 'lodash/noop';

import { ActionsTrigger } from '../triggers';
import { INTERCOM_APP_ID } from '../config';
Expand All @@ -35,7 +36,14 @@ export class UnwrappedApp extends React.Component {
static displayName = 'UnwrappedApp';

static propTypes = {
children: PropTypes.element.isRequired
children: PropTypes.element.isRequired,
dispatch: PropTypes.func,
location: PropTypes.shape()
};

static defaultProps = {
dispatch: noop,
location: { hash: '', pathname: '', search: '' }
};

static async fetchData(router, store, client) {
Expand Down
8 changes: 8 additions & 0 deletions src/pages/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import React, { PropTypes } from 'react';
import { connect } from 'react-redux';
import Helmet from 'react-helmet';
import noop from 'lodash/noop';

import { ArrayOfMessages as ArrayOfMessagesPropType } from '../prop-types/messages';
import { CurrentUser as CurrentUserPropType } from '../prop-types/users';
Expand Down Expand Up @@ -48,13 +49,20 @@ export class UnwrappedAuth extends React.Component {

static propTypes = {
current_user: CurrentUserPropType,
dispatch: PropTypes.func,
is_logged_in: PropTypes.bool,
location: PropTypes.shape(),
messages: ArrayOfMessagesPropType.isRequired,
ui: PropTypes.shape({
registrationSuccess: PropTypes.bool
}).isRequired
};

static defaultProps = {
dispatch: noop,
location: { hash: '', pathname: '', search: '' }
};

static async fetchData(router, store) {
const props = store.getState();
const currentUserId = props.get('current_user').get('id');
Expand Down
8 changes: 8 additions & 0 deletions src/pages/password-reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import React, { PropTypes } from 'react';
import { connect } from 'react-redux';
import Helmet from 'react-helmet';
import noop from 'lodash/noop';

import ApiClient from '../api/client';
import { API_HOST } from '../config';
Expand Down Expand Up @@ -64,11 +65,18 @@ export class PasswordResetPage extends React.Component {
static displayName = 'PasswordResetPage';

static propTypes = {
dispatch: PropTypes.func,
location: PropTypes.shape(),
ui: PropTypes.shape({
submitResetPassword: PropTypes.bool
}).isRequired
};

static defaultProps = {
dispatch: noop,
location: { hash: '', pathname: '', search: '' }
};

static fetchData(router, store) {
store.dispatch(attachContextualRoutes(
PasswordResetPage.displayName,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function getRouteName(route) {
return component.displayName || component.name;
}

export function getRoutesNames(routes) {
export function getRoutesNames(routes = []) {
return routes.reduce(
(acc, route) => (route.component && acc.push(getRouteName(route)), acc),
[]
Expand Down
2 changes: 1 addition & 1 deletion test/integration/components/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { Provider } from 'react-redux';
import { mount } from 'enzyme';
import sinon from 'sinon';

import Register, { UnwrappedRegister } from '../../../src/components/register';
import Register, { UnwrappedRegister } from '../../../src/components/register/v1';
import { initState } from '../../../src/store';
import initBookshelf from '../../../src/api/db';
import expect from '../../../test-helpers/expect';
Expand Down
10 changes: 5 additions & 5 deletions test/unit/pages/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ import i from 'immutable';

import { TestUtils, expect, React } from '../../../test-helpers/expect-unit';

import { UnwpappedAuth } from '../../../src/pages/auth';
import { UnwrappedAuth } from '../../../src/pages/auth';
import Messages from '../../../src/components/messages';
import Register from '../../../src/components/register';


describe('UnwpappedAuth page with redux', function () {
describe('UnwrappedAuth page with redux', function () {
// before(() => {
// sinon.stub(console, 'error', (warning) => { throw new Error(warning); });
// });
Expand All @@ -37,7 +37,7 @@ describe('UnwpappedAuth page with redux', function () {

it('MUST render important components', () => {
const renderer = TestUtils.createRenderer();
renderer.render(<UnwpappedAuth is_logged_in messages={i.List()} ui={i.Map()} />);
renderer.render(<UnwrappedAuth is_logged_in messages={i.List()} ui={i.Map()} />);

return expect(
renderer,
Expand All @@ -48,7 +48,7 @@ describe('UnwpappedAuth page with redux', function () {

it('MUST render passed messages', () => {
const renderer = TestUtils.createRenderer();
renderer.render(<UnwpappedAuth is_logged_in messages={i.fromJS([{ message: 'Im foo message' }])} ui={i.Map()} />);
renderer.render(<UnwrappedAuth is_logged_in messages={i.fromJS([{ message: 'Im foo message' }])} ui={i.Map()} />);

return expect(
renderer,
Expand All @@ -61,7 +61,7 @@ describe('UnwpappedAuth page with redux', function () {

it('MUST pass ui.registrationSuccess to Register component', () => {
const renderer = TestUtils.createRenderer();
renderer.render(<UnwpappedAuth is_logged_in messages={i.List()} ui={i.fromJS({ registrationSuccess: false })} />);
renderer.render(<UnwrappedAuth is_logged_in messages={i.List()} ui={i.fromJS({ registrationSuccess: false })} />);

return expect(
renderer,
Expand Down

0 comments on commit 54d66bd

Please sign in to comment.