A run with correct Prettier version

This commit is contained in:
Vesa Luusua 2017-01-19 13:44:50 +02:00
parent 30c3d5abfd
commit 4feb5e8087
37 changed files with 138 additions and 123 deletions

View file

@ -10,13 +10,11 @@ export const ClientApp = props => {
const { store } = props;
return (
<BrowserRouter>
{
({router}) => (
{({ router }) => (
<Provider store={store}>
<Routes router={router} />
</Provider>
)
}
)}
</BrowserRouter>
);
};
@ -29,13 +27,11 @@ export const ServerApp = props => {
const { url, context, store } = props;
return (
<ServerRouter location={url} context={context}>
{
({router}) => (
{({ router }) => (
<Provider store={store}>
<Routes router={router} />
</Provider>
)
}
)}
</ServerRouter>
);
};

View file

@ -5,10 +5,9 @@ import { Topbar } from '../../containers';
const scrollToTop = () => {
// Todo: this might need fine tuning later
window.scrollTo(0, 0);
}
};
class PageLayout extends Component {
componentDidMount() {
this.historyUnlisten = this.context.history.listen(() => scrollToTop());
}
@ -17,7 +16,6 @@ class PageLayout extends Component {
this.historyUnlisten();
}
render() {
const { className, title, children } = this.props;
return (

View file

@ -30,10 +30,12 @@ class AuthenticationPage extends Component {
const alternativeMethod = this.props.tab === 'login' ? toSignup : toLogin;
const currentMethod = this.props.tab === 'login' ? 'Log in' : 'Sign up';
const fromLoginMsg = from ? <p>
You must log in to view the page at
<code>{from.pathname}</code>
</p> : null;
const fromLoginMsg = from ? (
<p>
You must log in to view the page at
<code>{from.pathname}</code>
</p>
) : null;
return (
<PageLayout title={`Authentication page: ${this.props.tab} tab`}>
@ -51,7 +53,7 @@ AuthenticationPage.defaultProps = { location: {}, tab: 'signup' };
const { shape, string, object, oneOf, oneOfType } = PropTypes;
AuthenticationPage.propTypes = {
location: shape({ state: shape({ from: oneOfType([object, string]) }) }),
location: shape({ state: shape({ from: oneOfType([ object, string ]) }) }),
tab: oneOf([ 'login', 'signup' ]),
};

View file

@ -6,9 +6,11 @@ import AuthenticationPage from './AuthenticationPage';
describe('AuthenticationPage', () => {
it('matches snapshot', () => {
const component = renderer.create(
<BrowserRouter>
<AuthenticationPage location={{ state: { from: '/protected' } }} />
</BrowserRouter>,
(
<BrowserRouter>
<AuthenticationPage location={{ state: { from: '/protected' } }} />
</BrowserRouter>
),
);
const tree = component.toJSON();
expect(tree).toMatchSnapshot();

View file

@ -6,9 +6,11 @@ import CheckoutPage from './CheckoutPage';
describe('CheckoutPage', () => {
it('matches snapshot', () => {
const component = renderer.create(
<BrowserRouter>
<CheckoutPage params={{ listingId: 'some-listing-id' }} />
</BrowserRouter>,
(
<BrowserRouter>
<CheckoutPage params={{ listingId: 'some-listing-id' }} />
</BrowserRouter>
),
);
const tree = component.toJSON();
expect(tree).toMatchSnapshot();

View file

@ -1,4 +1,4 @@
import React from 'react';
import { PageLayout } from '../../components';
export default () => <PageLayout title="Contact details" />;
export default () => <PageLayout title="Contact details" />

View file

@ -6,9 +6,11 @@ import ContactDetailsPage from './ContactDetailsPage';
describe('ContactDetailsPage', () => {
it('matches snapshot', () => {
const component = renderer.create(
<BrowserRouter>
<ContactDetailsPage params={{ displayName: 'my-shop' }} />
</BrowserRouter>,
(
<BrowserRouter>
<ContactDetailsPage params={{ displayName: 'my-shop' }} />
</BrowserRouter>
),
);
const tree = component.toJSON();
expect(tree).toMatchSnapshot();

View file

@ -6,9 +6,11 @@ import ConversationPage from './ConversationPage';
describe('ConversationPage', () => {
it('matches snapshot', () => {
const component = renderer.create(
<BrowserRouter>
<ConversationPage params={{ id: 'some-conversation-id' }} />
</BrowserRouter>,
(
<BrowserRouter>
<ConversationPage params={{ id: 'some-conversation-id' }} />
</BrowserRouter>
),
);
const tree = component.toJSON();
expect(tree).toMatchSnapshot();

View file

@ -6,9 +6,11 @@ import EditProfilePage from './EditProfilePage';
describe('EditProfilePage', () => {
it('matches snapshot', () => {
const component = renderer.create(
<BrowserRouter>
<EditProfilePage params={{ displayName: 'my-shop' }} />
</BrowserRouter>,
(
<BrowserRouter>
<EditProfilePage params={{ displayName: 'my-shop' }} />
</BrowserRouter>
),
);
const tree = component.toJSON();
expect(tree).toMatchSnapshot();

View file

@ -8,7 +8,7 @@ describe('InboxPage', () => {
const component = renderer.create(
(
<BrowserRouter>
<InboxPage filter='inbox' />
<InboxPage filter="inbox" />
</BrowserRouter>
),
);

View file

@ -6,4 +6,4 @@ export default () => (
<PageLayout title="Landing page">
<Link to="/s?location=helsinki">Find studios</Link>
</PageLayout>
);
)

View file

@ -6,9 +6,11 @@ import LandingPage from './LandingPage';
describe('LandingPage', () => {
it('matches snapshot', () => {
const component = renderer.create(
<BrowserRouter>
<LandingPage />
</BrowserRouter>,
(
<BrowserRouter>
<LandingPage />
</BrowserRouter>
),
);
const tree = component.toJSON();
expect(tree).toMatchSnapshot();

View file

@ -6,9 +6,11 @@ import ListingPage from './ListingPage';
describe('ListingPage', () => {
it('matches snapshot', () => {
const component = renderer.create(
<BrowserRouter>
<ListingPage params={{ slug: 'really-nice-house-1234' }} />
</BrowserRouter>,
(
<BrowserRouter>
<ListingPage params={{ slug: 'really-nice-house-1234' }} />
</BrowserRouter>
),
);
const tree = component.toJSON();
expect(tree).toMatchSnapshot();

View file

@ -8,4 +8,4 @@ export default () => (
<li><Link to="/l/1234">Listing 1234</Link></li>
</ul>
</PageLayout>
);
)

View file

@ -6,9 +6,11 @@ import ManageListingsPage from './ManageListingsPage';
describe('ManageListingsPage', () => {
it('matches snapshot', () => {
const component = renderer.create(
<BrowserRouter>
<ManageListingsPage />
</BrowserRouter>,
(
<BrowserRouter>
<ManageListingsPage />
</BrowserRouter>
),
);
const tree = component.toJSON();
expect(tree).toMatchSnapshot();

View file

@ -6,4 +6,4 @@ export default () => (
<PageLayout title="Page not found">
<Link to="/">Index page</Link>
</PageLayout>
);
)

View file

@ -6,9 +6,11 @@ import NotFoundPage from './NotFoundPage';
describe('NotFoundPage', () => {
it('matches snapshot', () => {
const component = renderer.create(
<BrowserRouter>
<NotFoundPage />
</BrowserRouter>,
(
<BrowserRouter>
<NotFoundPage />
</BrowserRouter>
),
);
const tree = component.toJSON();
expect(tree).toMatchSnapshot();

View file

@ -1,4 +1,4 @@
import React from 'react';
import { PageLayout } from '../../components';
export default () => <PageLayout title="Notification settings" />;
export default () => <PageLayout title="Notification settings" />

View file

@ -6,9 +6,11 @@ import NotificationSettingsPage from './NotificationSettingsPage';
describe('NotificationSettingsPage', () => {
it('matches snapshot', () => {
const component = renderer.create(
<BrowserRouter>
<NotificationSettingsPage />
</BrowserRouter>,
(
<BrowserRouter>
<NotificationSettingsPage />
</BrowserRouter>
),
);
const tree = component.toJSON();
expect(tree).toMatchSnapshot();

View file

@ -13,7 +13,9 @@ const OrderPage = props => {
<Link to={`/order/${params.id}/details`}>Details tab</Link>
<p>Mobile layout needs different views for discussion and details.</p>
<p>
Discussion view is the default if route doesn't specify mobile tab (e.g. <i>/order/1234</i>)
Discussion view is the default if route doesn't specify mobile tab (e.g. <i>
/order/1234
</i>)
</p>
</PageLayout>
);
@ -21,6 +23,8 @@ const OrderPage = props => {
const { number, oneOfType, shape, string } = PropTypes;
OrderPage.propTypes = { params: shape({ id: oneOfType([number, string]).isRequired }).isRequired };
OrderPage.propTypes = {
params: shape({ id: oneOfType([ number, string ]).isRequired }).isRequired,
};
export default OrderPage;

View file

@ -6,9 +6,11 @@ import OrderPage from './OrderPage';
describe('OrderPage', () => {
it('matches snapshot', () => {
const component = renderer.create(
<BrowserRouter>
<OrderPage params={{ id: 1234 }} />
</BrowserRouter>,
(
<BrowserRouter>
<OrderPage params={{ id: 1234 }} />
</BrowserRouter>
),
);
const tree = component.toJSON();
expect(tree).toMatchSnapshot();

View file

@ -1,4 +1,4 @@
import React from 'react';
import { PageLayout } from '../../components';
export default () => <PageLayout title="Type new password" />;
export default () => <PageLayout title="Type new password" />

View file

@ -6,9 +6,11 @@ import PasswordChangePage from './PasswordChangePage';
describe('PasswordChangePage', () => {
it('matches snapshot', () => {
const component = renderer.create(
<BrowserRouter>
<PasswordChangePage />
</BrowserRouter>,
(
<BrowserRouter>
<PasswordChangePage />
</BrowserRouter>
),
);
const tree = component.toJSON();
expect(tree).toMatchSnapshot();

View file

@ -1,4 +1,4 @@
import React from 'react';
import { PageLayout } from '../../components';
export default () => <PageLayout title="Request new password" />;
export default () => <PageLayout title="Request new password" />

View file

@ -6,9 +6,11 @@ import PasswordForgottenPage from './PasswordForgottenPage';
describe('PasswordForgottenPage', () => {
it('matches snapshot', () => {
const component = renderer.create(
<BrowserRouter>
<PasswordForgottenPage />
</BrowserRouter>,
(
<BrowserRouter>
<PasswordForgottenPage />
</BrowserRouter>
),
);
const tree = component.toJSON();
expect(tree).toMatchSnapshot();

View file

@ -1,4 +1,4 @@
import React from 'react';
import { PageLayout } from '../../components';
export default () => <PageLayout title="Payment methods" />;
export default () => <PageLayout title="Payment methods" />

View file

@ -6,9 +6,11 @@ import PaymentMethodsPage from './PaymentMethodsPage';
describe('PaymentMethodsPage', () => {
it('matches snapshot', () => {
const component = renderer.create(
<BrowserRouter>
<PaymentMethodsPage />
</BrowserRouter>,
(
<BrowserRouter>
<PaymentMethodsPage />
</BrowserRouter>
),
);
const tree = component.toJSON();
expect(tree).toMatchSnapshot();

View file

@ -1,4 +1,4 @@
import React from 'react';
import { PageLayout } from '../../components';
export default () => <PageLayout title="Payout preferences" />;
export default () => <PageLayout title="Payout preferences" />

View file

@ -6,9 +6,11 @@ import PayoutPreferencesPage from './PayoutPreferencesPage';
describe('PayoutPreferencesPage', () => {
it('matches snapshot', () => {
const component = renderer.create(
<BrowserRouter>
<PayoutPreferencesPage />
</BrowserRouter>,
(
<BrowserRouter>
<PayoutPreferencesPage />
</BrowserRouter>
),
);
const tree = component.toJSON();
expect(tree).toMatchSnapshot();

View file

@ -6,9 +6,11 @@ import ProfilePage from './ProfilePage';
describe('ProfilePage', () => {
it('matches snapshot', () => {
const component = renderer.create(
<BrowserRouter>
<ProfilePage params={{ displayName: 'most-awesome-shop' }} />
</BrowserRouter>,
(
<BrowserRouter>
<ProfilePage params={{ displayName: 'most-awesome-shop' }} />
</BrowserRouter>
),
);
const tree = component.toJSON();
expect(tree).toMatchSnapshot();

View file

@ -13,7 +13,9 @@ const SalesConversationPage = props => {
<Link to={`/sale/${params.id}/details`}>Details tab</Link>
<p>Mobile layout needs different views for discussion and details.</p>
<p>
Discussion view is the default if route doesn't specify mobile tab (e.g. <i>/order/1234</i>)
Discussion view is the default if route doesn't specify mobile tab (e.g. <i>
/order/1234
</i>)
</p>
</PageLayout>
);

View file

@ -6,9 +6,11 @@ import SalesConversationPage from './SalesConversationPage';
describe('SalesConversationPage', () => {
it('matches snapshot', () => {
const component = renderer.create(
<BrowserRouter>
<SalesConversationPage params={{ id: 12345 }} />
</BrowserRouter>,
(
<BrowserRouter>
<SalesConversationPage params={{ id: 12345 }} />
</BrowserRouter>
),
);
const tree = component.toJSON();
expect(tree).toMatchSnapshot();

View file

@ -41,16 +41,16 @@ describe('SearchPageDucs', () => {
const addFilter1 = { type: ADD_FILTER, payload: filter1 };
const addFilter2 = { type: ADD_FILTER, payload: filter2 };
const reduced = reducer([], addFilter1);
const reducedWithInitialContent = reducer({ filters: [filter1] }, addFilter2);
expect(reduced).toEqual({ filters: [filter1] });
expect(reducedWithInitialContent).toEqual({ filters: [filter1, filter2] });
const reducedWithInitialContent = reducer({ filters: [ filter1 ] }, addFilter2);
expect(reduced).toEqual({ filters: [ filter1 ] });
expect(reducedWithInitialContent).toEqual({ filters: [ filter1, filter2 ] });
});
it('should handle duplicates ADD_FILTER', () => {
const filter = { location: 'helsinki' };
const addFilter = { type: ADD_FILTER, payload: filter };
const reducedWithInitialContent = reducer({ filters: [filter] }, addFilter);
expect(reducedWithInitialContent).toEqual({ filters: [filter] });
const reducedWithInitialContent = reducer({ filters: [ filter ] }, addFilter);
expect(reducedWithInitialContent).toEqual({ filters: [ filter ] });
});
});
});

View file

@ -5,4 +5,4 @@ export default () => (
<PageLayout title="Security">
<p>Change password, delete account</p>
</PageLayout>
);
)

View file

@ -6,9 +6,11 @@ import SecurityPage from './SecurityPage';
describe('SecurityPage', () => {
it('matches snapshot', () => {
const component = renderer.create(
<BrowserRouter>
<SecurityPage />
</BrowserRouter>,
(
<BrowserRouter>
<SecurityPage />
</BrowserRouter>
),
);
const tree = component.toJSON();
expect(tree).toMatchSnapshot();

View file

@ -35,7 +35,7 @@ export default (state = initialState, action) => {
default:
return state;
}
};
}
// Action Creators
let nextMessageId = 1;

View file

@ -10,12 +10,7 @@ describe('FlashNotification', () => {
const type = 'error';
const expectedAction = {
type: ADD_FLASH_NOTIFICATION,
payload: {
id: 'note_1',
type,
content,
isRead: false,
}
payload: { id: 'note_1', type, content, isRead: false },
};
const serializedExpectations = JSON.stringify(expectedAction);
const received = JSON.stringify(addFlashNotification(type, content));
@ -23,10 +18,7 @@ describe('FlashNotification', () => {
});
it('should create an action to remove a notification', () => {
const expectedAction = {
type: REMOVE_FLASH_NOTIFICATION,
payload: { id: 1 },
};
const expectedAction = { type: REMOVE_FLASH_NOTIFICATION, payload: { id: 1 } };
expect(removeFlashNotification(1)).toEqual(expectedAction);
});
@ -39,36 +31,21 @@ describe('FlashNotification', () => {
});
it('should handle ADD_FLASH_NOTIFICATION', () => {
const flashNote1 = {
id: 0,
type: 'error',
content: 'Run the tests',
isRead: false,
};
const flashNote2 = {
id: 0,
type: 'error',
content: 'Run the tests again',
isRead: false,
};
const flashNote1 = { id: 0, type: 'error', content: 'Run the tests', isRead: false };
const flashNote2 = { id: 0, type: 'error', content: 'Run the tests again', isRead: false };
const addFlashNote1 = { type: ADD_FLASH_NOTIFICATION, payload: flashNote1 };
const addFlashNote2 = { type: ADD_FLASH_NOTIFICATION, payload: flashNote2 };
const reduced = reducer([], addFlashNote1);
const reducedWithInitialContent = reducer([flashNote1], addFlashNote2);
expect(reduced).toEqual([flashNote1]);
expect(reducedWithInitialContent).toEqual([flashNote1, flashNote2]);
const reducedWithInitialContent = reducer([ flashNote1 ], addFlashNote2);
expect(reduced).toEqual([ flashNote1 ]);
expect(reducedWithInitialContent).toEqual([ flashNote1, flashNote2 ]);
});
it('should handle duplicates ADD_FILTER', () => {
const flashNote = {
id: 0,
type: 'error',
content: 'Run the tests',
isRead: false,
};
const flashNote = { id: 0, type: 'error', content: 'Run the tests', isRead: false };
const addFlashNote = { type: ADD_FLASH_NOTIFICATION, payload: flashNote };
const reducedWithInitialContent = reducer([flashNote], addFlashNote);
expect(reducedWithInitialContent).toEqual([flashNote]);
const reducedWithInitialContent = reducer([ flashNote ], addFlashNote);
expect(reducedWithInitialContent).toEqual([ flashNote ]);
});
});
});