generated from DTS-STN/next-template
-
Notifications
You must be signed in to change notification settings - Fork 2
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 #392 from DTS-STN/date-component
Removing DS Date.
- Loading branch information
Showing
11 changed files
with
71 additions
and
64 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
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
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
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,24 @@ | ||
import { render, screen } from '@testing-library/react' | ||
import '@testing-library/jest-dom/extend-expect' | ||
import { axe, toHaveNoViolations } from 'jest-axe' | ||
import { Date } from '../../components/Date' | ||
|
||
expect.extend(toHaveNoViolations) | ||
|
||
describe('Date', () => { | ||
it('renders Date', () => { | ||
render(<Date id="testID" date="20230331T00001" label="label" />) | ||
const title = screen.getByTestId('testID') | ||
const caption = screen.getByText('20230331') | ||
const label = screen.getByText('label') | ||
expect(title).toBeInTheDocument() | ||
expect(caption).toBeInTheDocument() | ||
expect(label).toBeInTheDocument() | ||
}) | ||
|
||
it('has no a11y viollations', async () => { | ||
const { container } = render(<Date id="testID" date="20230331" />) | ||
const results = await axe(container) | ||
expect(results).toHaveNoViolations() | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
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,35 @@ | ||
import PropTypes from 'prop-types' | ||
|
||
export function Date(props) { | ||
const { id, label, date } = props | ||
const dateFormatted = date ? date.split('T')[0] : 'NA' | ||
return ( | ||
<dl id={id} data-testid={id} className="mt-8 py-2 font-body"> | ||
<dt className="inline">{label}</dt> | ||
<dd className="inline"> | ||
{dateFormatted === 'NA' ? ( | ||
<time>{` ${dateFormatted}`}</time> | ||
) : ( | ||
<time dateTime={dateFormatted}>{` ${dateFormatted}`}</time> | ||
)} | ||
</dd> | ||
</dl> | ||
) | ||
} | ||
|
||
Date.propTypes = { | ||
/** | ||
* component id | ||
*/ | ||
id: PropTypes.string, | ||
|
||
/** | ||
* Text to show before date, defaults to "Date Modified: " | ||
*/ | ||
label: PropTypes.string, | ||
|
||
/** | ||
* Date string in format yyyyMMdd | ||
*/ | ||
date: PropTypes.string, | ||
} |
This file was deleted.
Oops, something went wrong.
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
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
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
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