From fdb1f96847c97499194e90bf37a374814da2303d Mon Sep 17 00:00:00 2001 From: Kimmo Puputti Date: Thu, 23 Feb 2017 13:37:49 +0200 Subject: [PATCH] Add test helpers for creating users and listings --- src/util/test-helpers.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/util/test-helpers.js b/src/util/test-helpers.js index e2021dac..c04a9b02 100644 --- a/src/util/test-helpers.js +++ b/src/util/test-helpers.js @@ -5,8 +5,11 @@ import toJson from 'enzyme-to-json'; import { IntlProvider } from 'react-intl'; import { BrowserRouter } from 'react-router-dom'; import { Provider } from 'react-redux'; +import { types } from 'sharetribe-sdk'; import configureStore from '../store'; +const { UUID, LatLng } = types; + // Provide all the context for components that connect to the Redux // store, i18n, router, etc. export const TestProvider = props => { @@ -46,3 +49,25 @@ export const renderDeep = component => { ); return comp.toJSON(); }; + +// Create a user that conforms to the util/propTypes user schema +export const createUser = id => ({ + id: new UUID(id), + type: 'user', + attributes: { + email: '${id}@example.com', + profile: { firstName: `${id} first name`, lastName: `${id} last name`, slug: `${id}-slug` }, + }, +}); + +// Create a user that conforms to the util/propTypes listing schema +export const createListing = id => ({ + id: new UUID(id), + type: 'listing', + attributes: { + title: `${id} title`, + description: `${id} description`, + address: `${id} address`, + geolocation: new LatLng(40, 60), + }, +});