Skip to content

Commit

Permalink
test: add TaxonomyDetailSideCard.test.jsx
Browse files Browse the repository at this point in the history
  • Loading branch information
rpenido committed Oct 25, 2023
1 parent db61ce0 commit bfa0953
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions src/taxonomy/taxonomy-detail/TaxonomyDetailSideCard.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React from 'react';
import { IntlProvider, injectIntl } from '@edx/frontend-platform/i18n';
import { initializeMockApp } from '@edx/frontend-platform';
import { AppProvider } from '@edx/frontend-platform/react';
import { render } from '@testing-library/react';
import PropTypes from 'prop-types';

import initializeStore from '../../store';

import TaxonomyDetailSideCard from './TaxonomyDetailSideCard';

let store;

const data = {
id: 1,
name: 'Taxonomy 1',
description: 'This is a description',
};

const TaxonomyCardComponent = ({ taxonomy }) => (
<AppProvider store={store}>
<IntlProvider locale="en" messages={{}}>
<TaxonomyDetailSideCard intl={injectIntl} taxonomy={taxonomy} />
</IntlProvider>
</AppProvider>
);

TaxonomyCardComponent.propTypes = {
taxonomy: PropTypes.shape({
name: PropTypes.string,
description: PropTypes.string,
}).isRequired,
};

describe('<TaxonomyDetailSideCard/>', async () => {
beforeEach(async () => {
initializeMockApp({
authenticatedUser: {
userId: 3,
username: 'abc123',
administrator: true,
roles: [],
},
});
store = initializeStore();
});

it('should render title and description of the card', () => {
const { getByText } = render(<TaxonomyDetailSideCard taxonomy={data} />);
expect(getByText(data.name)).toBeInTheDocument();
expect(getByText(data.description)).toBeInTheDocument();
});
});

0 comments on commit bfa0953

Please sign in to comment.