Skip to content

Commit 96b52f3

Browse files
committed
test: fix failing test
1 parent 62ad8ae commit 96b52f3

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

lib/VersionHistory/VersionCard/VersionCard.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ import css from './VersionCard.css';
1616
const itemFormatter = (item, i) => (<li key={i} className={css.changedRecord}>{item}</li>);
1717

1818
const VersionCard = ({
19-
changedFields,
19+
changedFields = [],
2020
id,
2121
isCurrent,
2222
isLatest,
23-
isSystemChange,
23+
isSystemChange = false,
2424
onSelect,
2525
source,
2626
title,
@@ -79,7 +79,7 @@ const VersionCard = ({
7979
);
8080
}
8181

82-
if (changedFields) {
82+
if (changedFields.length) {
8383
return (
8484
<>
8585
<FormattedMessage

lib/VersionHistory/VersionCard/VersionCard.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe('VersionCard', () => {
3636
it('should display version history card with system update', () => {
3737
renderVersionCard({ isSystemChange: true });
3838

39-
expect(screen.getByText(/versionChange/)).toBeInTheDocument();
39+
expect(screen.getByText(/systemChange/)).toBeInTheDocument();
4040
});
4141

4242
it('should call \'onSelect\' when \'View this version\' icon button was clicked', async () => {

lib/VersionHistory/VersionHistoryPane/VersionHistoryPane.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ describe('VersionHistoryPane', () => {
110110
systemUpdatedFields: ['searchLocationId'],
111111
});
112112

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

116116
it('should not display version cards without changed fields', () => {

lib/VersionHistory/getFieldLabels.test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ const paths = [
1616
const intl = { formatMessage: ({ id }) => id };
1717

1818
describe('getFieldLabels', () => {
19+
beforeEach(() => {
20+
jest.clearAllMocks();
21+
});
22+
1923
it('should use keys of labelsMap as regexp to parse labels of paths', () => {
2024
expect(getFieldLabels(intl, paths, labelsMap).changedFields).toEqual(expect.arrayContaining([
2125
...Object.values(labelsMap),
@@ -38,7 +42,7 @@ describe('getFieldLabels', () => {
3842
it('should isSystemChange equal `true` if there are only systemChanges', () => {
3943
const systemUpdatedFields = ['fundDistribution'];
4044

41-
const result = getFieldLabels(intl, paths, labelsMap, [], systemUpdatedFields);
45+
const result = getFieldLabels(intl, ['fundDistribution'], labelsMap, [], systemUpdatedFields);
4246

4347
expect(result.isSystemChange).toBeTruthy();
4448
});

0 commit comments

Comments
 (0)