Skip to content

Commit

Permalink
fix(uaa-parity): Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JChan106 committed Jan 8, 2025
1 parent c8e5062 commit 6f9e69a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const CollapsedVersion = (props: Props): React.Node => {
// $FlowFixMe
const {
action_by,
action_type,
action_type = ACTION_TYPE_CREATED,
collaborators,
id,
intl,
Expand All @@ -132,6 +132,7 @@ const CollapsedVersion = (props: Props): React.Node => {
version_start,
version_end,
} = props;
// $FlowFixMe
const action = shouldUseUAA ? action_type : selectors.getVersionAction(props);

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { render, screen } from '@testing-library/react';
import { IntlProvider } from 'react-intl';
import { ACTION_TYPE_RESTORED } from 'constants';
import { ACTION_TYPE_CREATED, ACTION_TYPE_RESTORED, ACTION_TYPE_TRASHED } from '../../../../../constants';
import CollapsedVersion from '../CollapsedVersion';
import selectors from '../../../../common/selectors/version';

Expand Down Expand Up @@ -66,17 +66,22 @@ describe('elements/content-sidebar/ActivityFeed/version/CollapsedVersion', () =>
expect(screen.queryByText('Person one')).not.toBeInTheDocument();
});

test('should correctly render when shouldUseUAA is true', () => {
test.each`
actionType | actionText
${ACTION_TYPE_RESTORED} | ${'restored v'}
${ACTION_TYPE_TRASHED} | ${'deleted v'}
${ACTION_TYPE_CREATED} | ${'uploaded v'}
`('should correctly render when shouldUseUAA is true with actionType $actionType', ({ actionType, actionText }) => {
renderComponent({
shouldUseUAA: true,
action_type: ACTION_TYPE_RESTORED,
action_by: [{ name: 'John Doe', id: 1 }],
action_type: actionType,
action_by: [{ name: 'John Doe', id: 3 }],
version_start: 2,
version_end: 4,
});

expect(screen.getByText('John Doe')).toBeInTheDocument();
expect(screen.getByText('restored v')).toBeInTheDocument();
expect(screen.getByText(actionText)).toBeInTheDocument();
expect(screen.getByText('2 - 4')).toBeInTheDocument();
});
});

0 comments on commit 6f9e69a

Please sign in to comment.