mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-29 05:00:43 +10:00
Make custom config stable in tests
This commit is contained in:
parent
80edfd843f
commit
87244c866b
3 changed files with 22 additions and 30 deletions
|
|
@ -95,8 +95,6 @@ const categoryLabel = (categories, key) => {
|
|||
return cat ? cat.label : key;
|
||||
};
|
||||
|
||||
// TODO: price unit (per x), custom fields, contact, reviews
|
||||
// N.B. All the presentational content needs to be extracted to their own components
|
||||
export class ListingPageComponent extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
|
@ -199,6 +197,8 @@ export class ListingPageComponent extends Component {
|
|||
fetchReviewsError,
|
||||
sendEnquiryInProgress,
|
||||
sendEnquiryError,
|
||||
categoriesConfig,
|
||||
amenitiesConfig,
|
||||
} = this.props;
|
||||
|
||||
const isBook = !!parse(location.search).book;
|
||||
|
|
@ -249,7 +249,7 @@ export class ListingPageComponent extends Component {
|
|||
const category =
|
||||
publicData && publicData.category ? (
|
||||
<span>
|
||||
{categoryLabel(config.custom.categories, publicData.category)}
|
||||
{categoryLabel(categoriesConfig, publicData.category)}
|
||||
<span className={css.separator}>•</span>
|
||||
</span>
|
||||
) : null;
|
||||
|
|
@ -434,7 +434,7 @@ export class ListingPageComponent extends Component {
|
|||
/>
|
||||
<SectionDescription description={description} />
|
||||
<SectionFeatures
|
||||
options={config.custom.amenities}
|
||||
options={amenitiesConfig}
|
||||
selectedOptions={publicData.amenities}
|
||||
/>
|
||||
<SectionRulesMaybe publicData={publicData} />
|
||||
|
|
@ -495,6 +495,8 @@ ListingPageComponent.defaultProps = {
|
|||
reviews: [],
|
||||
fetchReviewsError: null,
|
||||
sendEnquiryError: null,
|
||||
categoriesConfig: config.custom.categories,
|
||||
amenitiesConfig: config.custom.amenities,
|
||||
};
|
||||
|
||||
ListingPageComponent.propTypes = {
|
||||
|
|
|
|||
|
|
@ -30,6 +30,14 @@ import ActionBarMaybe from './ActionBarMaybe';
|
|||
const { UUID } = sdkTypes;
|
||||
const noop = () => null;
|
||||
|
||||
const categoriesConfig = [{ key: 'cat1', label: 'Cat 1' }, { key: 'cat2', label: 'Cat 2' }];
|
||||
|
||||
const amenitiesConfig = [
|
||||
{ key: 'feat1', label: 'Feat 1' },
|
||||
{ key: 'feat2', label: 'Feat 2' },
|
||||
{ key: 'feat3', label: 'Feat 3' },
|
||||
];
|
||||
|
||||
describe('ListingPage', () => {
|
||||
it('matches snapshot', () => {
|
||||
const currentUser = createCurrentUser('user-2');
|
||||
|
|
@ -67,6 +75,8 @@ describe('ListingPage', () => {
|
|||
onResendVerificationEmail: noop,
|
||||
sendEnquiryInProgress: false,
|
||||
onSendEnquiry: noop,
|
||||
categoriesConfig,
|
||||
amenitiesConfig,
|
||||
};
|
||||
|
||||
const tree = renderShallow(<ListingPageComponent {...props} />);
|
||||
|
|
|
|||
|
|
@ -154,36 +154,16 @@ exports[`ListingPage matches snapshot 1`] = `
|
|||
options={
|
||||
Array [
|
||||
Object {
|
||||
"key": "towels",
|
||||
"label": "Towels",
|
||||
"key": "feat1",
|
||||
"label": "Feat 1",
|
||||
},
|
||||
Object {
|
||||
"key": "bathroom",
|
||||
"label": "Bathroom",
|
||||
"key": "feat2",
|
||||
"label": "Feat 2",
|
||||
},
|
||||
Object {
|
||||
"key": "swimming_pool",
|
||||
"label": "Swimming pool",
|
||||
},
|
||||
Object {
|
||||
"key": "own_drinks",
|
||||
"label": "Own drinks allowed",
|
||||
},
|
||||
Object {
|
||||
"key": "jacuzzi",
|
||||
"label": "Jacuzzi",
|
||||
},
|
||||
Object {
|
||||
"key": "audiovisual_entertainment",
|
||||
"label": "Audiovisual entertainment",
|
||||
},
|
||||
Object {
|
||||
"key": "barbeque",
|
||||
"label": "Barbeque",
|
||||
},
|
||||
Object {
|
||||
"key": "own_food_allowed",
|
||||
"label": "Own food allowed",
|
||||
"key": "feat3",
|
||||
"label": "Feat 3",
|
||||
},
|
||||
]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue