forked from openedx/frontend-app-authoring
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add TaxonomyDetailSideCard.test.jsx
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
src/taxonomy/taxonomy-detail/TaxonomyDetailSideCard.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |