Skip to content

Commit

Permalink
updating unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danielevalverde committed Jan 21, 2025
1 parent 8954e9d commit 567950f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
12 changes: 6 additions & 6 deletions src/app/components/media/MediaOrigin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@ import CheckMediaOrigin from '../../CheckMediaOrigin';

describe('<MediaOrigin />', () => {
it('should render a button with the correct icon and message for each type', () => {
const tiplineSubmitted = mountWithIntl(<MediaOrigin type={CheckMediaOrigin.TIPLINE_SUBMITTED} />);
const tiplineSubmitted = mountWithIntl(<MediaOrigin media_cluster_origin={CheckMediaOrigin.TIPLINE_SUBMITTED} media_cluster_origin_user="Smooch" />);
expect(tiplineSubmitted.find(Tipline).length).toEqual(1);
expect(tiplineSubmitted.html()).toMatch('Tipline Submitted');

const userAdded = mountWithIntl(<MediaOrigin type={CheckMediaOrigin.USER_ADDED} user="John Doe" />);
const userAdded = mountWithIntl(<MediaOrigin media_cluster_origin={CheckMediaOrigin.USER_ADDED} media_cluster_origin_user="John Doe" />);
expect(userAdded.find(PersonAdd).length).toEqual(1);
expect(userAdded.html()).toMatch('User Added');

const userMerged = mountWithIntl(<MediaOrigin type={CheckMediaOrigin.USER_MERGED} user="John Doe" />);
const userMerged = mountWithIntl(<MediaOrigin media_cluster_origin={CheckMediaOrigin.USER_MERGED} media_cluster_origin_user="John Doe" />);
expect(userMerged.find(Person).length).toEqual(1);
expect(userMerged.html()).toMatch('User Merged');

const userMatched = mountWithIntl(<MediaOrigin type={CheckMediaOrigin.USER_MATCHED} user="John Doe" />);
const userMatched = mountWithIntl(<MediaOrigin media_cluster_origin={CheckMediaOrigin.USER_MATCHED} media_cluster_origin_user="John Doe" />);
expect(userMatched.find(PersonCheck).length).toEqual(1);
expect(userMatched.html()).toMatch('User Matched');

const autoMatched = mountWithIntl(<MediaOrigin type={CheckMediaOrigin.AUTO_MATCHED} />);
const autoMatched = mountWithIntl(<MediaOrigin media_cluster_origin={CheckMediaOrigin.AUTO_MATCHED} media_cluster_origin_user="Alegre"/>);
expect(autoMatched.find(Bolt).length).toEqual(1);
expect(autoMatched.html()).toMatch('Auto Matched');
});

it('should return null for invalid type', () => {
const wrapper = mountWithIntl(<MediaOrigin type={99} />);
const wrapper = mountWithIntl(<MediaOrigin media_cluster_origin={99} media_cluster_origin_user={'user'}/>);
expect(wrapper.find('FormattedMessage').length).toEqual(0);
});
});
20 changes: 10 additions & 10 deletions src/app/components/media/MediaOriginBanner.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,33 @@ import Tipline from '../../icons/question_answer.svg';
import CheckMediaOrigin from '../../CheckMediaOrigin';

describe('<MediaBanner />', () => {
const timestamp = 1736876257;
const cluster = 'Cluster A';
const user = 'Bruce';
const media_cluster_origin_timestamp = 1736876257;
const media_cluster_relationship ={ confirmed_by: {name: 'Cluster A'}, target: { title: 'Cluster B' }};
const media_cluster_origin_user = 'Bruce';
it('should render a banner with the correct icon and message for each type', () => {
const tiplineSubmitted = mountWithIntl(<MediaBanner cluster={cluster} timestamp={timestamp} type={CheckMediaOrigin.TIPLINE_SUBMITTED} user={user} />);
const tiplineSubmitted = mountWithIntl(<MediaBanner media_cluster_relationship={media_cluster_relationship} media_cluster_origin_timestamp={media_cluster_origin_timestamp} media_cluster_origin={CheckMediaOrigin.TIPLINE_SUBMITTED} media_cluster_origin_user={media_cluster_origin_user} />);
expect(tiplineSubmitted.find(Tipline).length).toEqual(1);
expect(tiplineSubmitted.html()).toContain('This media was submitted via <strong>Tipline</strong>');

const userAdded = mountWithIntl(<MediaBanner cluster={cluster} timestamp={timestamp} type={CheckMediaOrigin.USER_ADDED} user={user} />);
const userAdded = mountWithIntl(<MediaBanner media_cluster_relationship={media_cluster_relationship} media_cluster_origin_timestamp={media_cluster_origin_timestamp} media_cluster_origin={CheckMediaOrigin.USER_ADDED} media_cluster_origin_user={media_cluster_origin_user} />);
expect(userAdded.find(PersonAdd).length).toEqual(1);
expect(userAdded.html()).toContain('This media was added to the cluster by');

const userMerged = mountWithIntl(<MediaBanner cluster={cluster} timestamp={timestamp} type={CheckMediaOrigin.USER_MERGED} user={user} />);
const userMerged = mountWithIntl(<MediaBanner media_cluster_relationship={media_cluster_relationship} media_cluster_origin_timestamp={media_cluster_origin_timestamp} media_cluster_origin={CheckMediaOrigin.USER_MERGED} media_cluster_origin_user={media_cluster_origin_user} />);
expect(userMerged.find(Person).length).toEqual(1);
expect(userMerged.html()).toContain('This media was added to the cluster by');
expect(userMerged.html()).toContain('This media was merged to the cluster by');

const userMatched = mountWithIntl(<MediaBanner cluster={cluster} timestamp={timestamp} type={CheckMediaOrigin.USER_MATCHED} user={user} />);
const userMatched = mountWithIntl(<MediaBanner media_cluster_relationship={media_cluster_relationship} media_cluster_origin_timestamp={media_cluster_origin_timestamp} media_cluster_origin={CheckMediaOrigin.USER_MATCHED} media_cluster_origin_user={media_cluster_origin_user} />);
expect(userMatched.find(PersonCheck).length).toEqual(1);
expect(userMatched.html()).toContain('This media was added to the cluster by');

const autoMatched = mountWithIntl(<MediaBanner cluster={cluster} timestamp={timestamp} type={CheckMediaOrigin.AUTO_MATCHED} user={user} />);
const autoMatched = mountWithIntl(<MediaBanner media_cluster_relationship={media_cluster_relationship} media_cluster_origin_timestamp={media_cluster_origin_timestamp} media_cluster_origin={CheckMediaOrigin.AUTO_MATCHED} media_cluster_origin_user={media_cluster_origin_user} />);
expect(autoMatched.find(Bolt).length).toEqual(1);
expect(autoMatched.html()).toContain('This media was automatically matched to the cluster');
});

it('should return null for invalid type', () => {
const wrapper = mountWithIntl(<MediaBanner cluster={cluster} timestamp={timestamp} type={99} user={user} />);
const wrapper = mountWithIntl(<MediaBanner media_cluster_relationship={media_cluster_relationship} media_cluster_origin_timestamp={media_cluster_origin_timestamp} media_cluster_origin={99} media_cluster_origin_user={media_cluster_origin_user} />);
expect(wrapper.find('FormattedMessage').length).toEqual(0);
});
});

0 comments on commit 567950f

Please sign in to comment.