forked from City-of-Helsinki/servicemap-ui
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #235 from City-of-Turku/develop
Release v1.7.5
- Loading branch information
Showing
59 changed files
with
1,094 additions
and
769 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/components/EcoCounter/TrafficCounters/CounterActiveText/CounterActiveText.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { useIntl } from 'react-intl'; | ||
import { Typography } from '@mui/material'; | ||
import styled from '@emotion/styled'; | ||
import { formatFullDates } from '../../utils'; | ||
|
||
/** | ||
* Render text that shows from and until dates. | ||
* @prop {string} dataFrom | ||
* @prop {string} dataUntil | ||
* @returns JSX eement | ||
*/ | ||
const CounterActiveText = ({ dataFrom, dataUntil }) => { | ||
const intl = useIntl(); | ||
const dataFromFormat = formatFullDates(dataFrom); | ||
const dataUntilFormat = formatFullDates(dataUntil); | ||
|
||
return ( | ||
<StyledTextContainer> | ||
<Typography variant="body2" sx={{ mb: '0.4rem' }}> | ||
{intl.formatMessage( | ||
{ id: 'ecocounter.station.counts.period' }, | ||
{ value1: dataFromFormat, value2: dataUntilFormat }, | ||
)} | ||
</Typography> | ||
</StyledTextContainer> | ||
); | ||
}; | ||
|
||
const StyledTextContainer = styled.div(({ theme }) => ({ | ||
textAlign: 'center', | ||
margin: `${theme.spacing(1)} 0`, | ||
})); | ||
|
||
CounterActiveText.propTypes = { | ||
dataFrom: PropTypes.string, | ||
dataUntil: PropTypes.string, | ||
}; | ||
|
||
CounterActiveText.defaultProps = { | ||
dataFrom: '', | ||
dataUntil: '', | ||
}; | ||
|
||
export default CounterActiveText; |
26 changes: 26 additions & 0 deletions
26
...mponents/EcoCounter/TrafficCounters/CounterActiveText/__tests__/CounterActiveText.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* eslint-disable react/jsx-props-no-spreading */ | ||
// Link.react.test.js | ||
import React from 'react'; | ||
import CounterActiveText from '../index'; | ||
import { getRenderWithProviders } from '../../../../../../jestUtils'; | ||
|
||
const mockProps = { | ||
dataFrom: '2020-01-01', | ||
dataUntil: '2023-10-10', | ||
}; | ||
|
||
const renderWithProviders = getRenderWithProviders({}); | ||
|
||
describe('<CounterActiveText />', () => { | ||
it('should work', () => { | ||
const { container } = renderWithProviders(<CounterActiveText {...mockProps} />); | ||
expect(container).toMatchSnapshot(); | ||
}); | ||
|
||
it('does show text correctly', () => { | ||
const { container } = renderWithProviders(<CounterActiveText {...mockProps} />); | ||
|
||
const p = container.querySelectorAll('p'); | ||
expect(p[0].textContent).toEqual('Laskentatiedot ovat väliltä 01.01.2020 - 10.10.2023'); | ||
}); | ||
}); |
15 changes: 15 additions & 0 deletions
15
.../TrafficCounters/CounterActiveText/__tests__/__snapshots__/CounterActiveText.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<CounterActiveText /> should work 1`] = ` | ||
<div> | ||
<div | ||
class="css-aavt1n" | ||
> | ||
<p | ||
class="MuiTypography-root MuiTypography-body2 css-1bvqycf-MuiTypography-root" | ||
> | ||
Laskentatiedot ovat väliltä 01.01.2020 - 10.10.2023 | ||
</p> | ||
</div> | ||
</div> | ||
`; |
3 changes: 3 additions & 0 deletions
3
src/components/EcoCounter/TrafficCounters/CounterActiveText/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import CounterActiveText from './CounterActiveText'; | ||
|
||
export default CounterActiveText; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.