Add createOwnListing test data helper, and start using it.

Fixes propType warnings in tests
This commit is contained in:
Mikko Koski 2018-01-18 16:33:55 +02:00
parent 6131235534
commit 5051eaf43a
3 changed files with 22 additions and 4 deletions

View file

@ -1,7 +1,7 @@
/* eslint-disable no-console */
import React from 'react';
import ManageListingCard from './ManageListingCard';
import { createListing, fakeIntl } from '../../util/test-data';
import { createOwnListing, fakeIntl } from '../../util/test-data';
const noop = () => null;
@ -17,7 +17,7 @@ export const ManageListingCardWrapped = {
hasClosingError: false,
hasOpeningError: false,
intl: fakeIntl,
listing: createListing('listing1'),
listing: createOwnListing('listing1'),
isMenuOpen: false,
onCloseListing: noop,
onOpenListing: noop,

View file

@ -1,6 +1,6 @@
import React from 'react';
import { renderShallow } from '../../util/test-helpers';
import { createUser, createListing, fakeIntl } from '../../util/test-data';
import { createUser, createOwnListing, fakeIntl } from '../../util/test-data';
import { ManageListingCardComponent } from './ManageListingCard';
const noop = () => null;
@ -10,7 +10,7 @@ describe('ManageListingCard', () => {
const tree = renderShallow(
<ManageListingCardComponent
history={{ push: noop }}
listing={createListing('listing1')}
listing={createOwnListing('listing1')}
intl={fakeIntl}
isMenuOpen={false}
onCloseListing={noop}

View file

@ -92,6 +92,24 @@ export const createListing = (id, attributes = {}, includes = {}) => ({
...includes,
});
// Create a user that conforms to the util/types ownListing schema
export const createOwnListing = (id, attributes = {}, includes = {}) => ({
id: new UUID(id),
type: 'ownListing',
attributes: {
title: `${id} title`,
description: `${id} description`,
address: `${id} address`,
geolocation: new LatLng(40, 60),
closed: false,
deleted: false,
price: new Money(5500, 'USD'),
customAttributes: {},
...attributes,
},
...includes,
});
export const createTxTransition = options => {
return {
at: new Date(Date.UTC(2017, 4, 1)),