Skip to content

Commit

Permalink
test: fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
alisher-epam committed Nov 29, 2024
1 parent 62ad8ae commit 96b52f3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/VersionHistory/VersionCard/VersionCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import css from './VersionCard.css';
const itemFormatter = (item, i) => (<li key={i} className={css.changedRecord}>{item}</li>);

const VersionCard = ({
changedFields,
changedFields = [],
id,
isCurrent,
isLatest,
isSystemChange,
isSystemChange = false,
onSelect,
source,
title,
Expand Down Expand Up @@ -79,7 +79,7 @@ const VersionCard = ({
);
}

if (changedFields) {
if (changedFields.length) {
return (
<>
<FormattedMessage
Expand Down
2 changes: 1 addition & 1 deletion lib/VersionHistory/VersionCard/VersionCard.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('VersionCard', () => {
it('should display version history card with system update', () => {
renderVersionCard({ isSystemChange: true });

expect(screen.getByText(/versionChange/)).toBeInTheDocument();
expect(screen.getByText(/systemChange/)).toBeInTheDocument();
});

it('should call \'onSelect\' when \'View this version\' icon button was clicked', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ describe('VersionHistoryPane', () => {
systemUpdatedFields: ['searchLocationId'],
});

expect(screen.getByText('stripes-acq-components.versionHistory.card.systemChange')).toBeInTheDocument();
expect(screen.getByText(/systemChange/)).toBeInTheDocument();
});

it('should not display version cards without changed fields', () => {
Expand Down
6 changes: 5 additions & 1 deletion lib/VersionHistory/getFieldLabels.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ const paths = [
const intl = { formatMessage: ({ id }) => id };

describe('getFieldLabels', () => {
beforeEach(() => {
jest.clearAllMocks();
});

it('should use keys of labelsMap as regexp to parse labels of paths', () => {
expect(getFieldLabels(intl, paths, labelsMap).changedFields).toEqual(expect.arrayContaining([
...Object.values(labelsMap),
Expand All @@ -38,7 +42,7 @@ describe('getFieldLabels', () => {
it('should isSystemChange equal `true` if there are only systemChanges', () => {
const systemUpdatedFields = ['fundDistribution'];

const result = getFieldLabels(intl, paths, labelsMap, [], systemUpdatedFields);
const result = getFieldLabels(intl, ['fundDistribution'], labelsMap, [], systemUpdatedFields);

expect(result.isSystemChange).toBeTruthy();
});
Expand Down

0 comments on commit 96b52f3

Please sign in to comment.