Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { render, screen } from '@testing-library/react';
import { render, screen, getDefaultNormalizer } from '@testing-library/react';
import { Timestamp, TimestampFormat, TimestampTooltipVariant } from '../Timestamp';

jest.mock('../../Tooltip', () => ({
Expand Down Expand Up @@ -33,7 +33,9 @@ test('Renders component', () => {
test('Renders with current date by default with default formatting', () => {
render(<Timestamp />);

expect(screen.getByText(new Date().toLocaleString())).toBeInTheDocument();
expect(
screen.getByText(new Date().toLocaleString(), { normalizer: getDefaultNormalizer({ collapseWhitespace: false }) })
).toBeInTheDocument();
});

test('Renders with correct datetime attribute with current date by default', () => {
Expand All @@ -42,7 +44,7 @@ test('Renders with correct datetime attribute with current date by default', ()
// we want an ISO value without the ms to expect as the datetime value.
const isoDateWithoutMS = new Date().toISOString().split('.')[0];

expect(screen.getByText(new Date().toLocaleString())).toHaveAttribute(
expect(screen.getByText(new Date().toLocaleString(), { normalizer: getDefaultNormalizer({ collapseWhitespace: false }) })).toHaveAttribute(
'datetime',
expect.stringMatching(isoDateWithoutMS)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exports[`Matches snapshot 1`] = `
class="pf-c-timestamp__text"
datetime="2022-01-01T00:00:00.000Z"
>
1/1/2022, 12:00:00 AM
1/1/2022, 12:00:00AM
</time>
</span>
</DocumentFragment>
Expand Down
3 changes: 2 additions & 1 deletion packages/react-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"analyze": "yarn build:docs --analyze",
"build:docs": "pf-docs-framework build all --legacySSL",
"clean": "rimraf .cache public static/assets static/base.css src/generated/**/*.js",
"develop": "pf-docs-framework start",
"develop": "./startDevServer.sh",
"start": "pf-docs-framework start",
"serve": "pf-docs-framework serve public",
"screenshots": "pf-docs-framework screenshots --urlPrefix http://localhost:5000",
"test:a11y": "patternfly-a11y --config patternfly-a11y.config"
Expand Down
12 changes: 12 additions & 0 deletions packages/react-docs/startDevServer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

STR=$NODE_OPTIONS
SUB='--openssl-legacy-provider'

if [[ "$STR" != *"$SUB"* ]]; then
NEW_OPTIONS="$NODE_OPTIONS --openssl-legacy-provider"
export NODE_OPTIONS="${NEW_OPTIONS}"
echo "NODE_OPTIONS: ${NODE_OPTIONS}"
fi

yarn start