Skip to content

Commit c11de6a

Browse files
committed
Add cost display component
1 parent ad3fe05 commit c11de6a

File tree

6 files changed

+69
-0
lines changed

6 files changed

+69
-0
lines changed

generate-react-cli.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"usesTypeScript": false,
3+
"usesStyledComponents": false,
4+
"testLibrary": "Testing Library",
5+
"component": {
6+
"default": {
7+
"path": "src/components",
8+
"withStyle": true,
9+
"withTest": true,
10+
"withStory": true,
11+
"withLazy": true
12+
}
13+
},
14+
"usesCssModule": true,
15+
"cssPreprocessor": "css"
16+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import styles from './CostDisplay.module.css';
4+
5+
const CostDisplay = ({ cost }) => (
6+
<div className={styles.CostDisplay} data-testid="CostDisplay">
7+
Cost: {cost}
8+
</div>
9+
);
10+
11+
CostDisplay.propTypes = {};
12+
13+
CostDisplay.defaultProps = {};
14+
15+
export default CostDisplay;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React, { lazy, Suspense } from 'react';
2+
3+
const LazyCostDisplay = lazy(() => import('./CostDisplay'));
4+
5+
const CostDisplay = props => (
6+
<Suspense fallback={null}>
7+
<LazyCostDisplay {...props} />
8+
</Suspense>
9+
);
10+
11+
export default CostDisplay;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.CostDisplay {}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* eslint-disable */
2+
import CostDisplay from './CostDisplay';
3+
4+
export default {
5+
title: "CostDisplay",
6+
};
7+
8+
export const Default = () => <CostDisplay />;
9+
10+
Default.story = {
11+
name: 'default',
12+
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React from 'react';
2+
import { render, screen } from '@testing-library/react';
3+
import '@testing-library/jest-dom';
4+
import CostDisplay from './CostDisplay';
5+
6+
describe('<CostDisplay />', () => {
7+
test('it should mount', () => {
8+
render(<CostDisplay />);
9+
10+
const CostDisplay = screen.getByTestId('CostDisplay');
11+
12+
expect(CostDisplay).toBeInTheDocument();
13+
});
14+
});

0 commit comments

Comments
 (0)