feat: update related program location (#104)

This commit is contained in:
leangseu-edx
2023-02-13 14:12:27 -05:00
committed by GitHub
parent a13085a6a1
commit 0933d185af
51 changed files with 1507 additions and 32 deletions

View File

@@ -4,19 +4,23 @@ import PropTypes from 'prop-types';
import { Alert } from '@edx/paragon';
import { Info } from '@edx/paragon/icons';
export const Banner = ({ children, variant, icon }) => (
<Alert variant={variant} className="mb-0" icon={icon}>
export const Banner = ({
children, variant, icon, className,
}) => (
<Alert variant={variant} className={className} icon={icon}>
{children}
</Alert>
);
Banner.defaultProps = {
icon: Info,
variant: 'info',
className: 'mb-0',
};
Banner.propTypes = {
variant: PropTypes.string,
icon: PropTypes.func,
children: PropTypes.node.isRequired,
className: PropTypes.string,
};
export default Banner;

View File

@@ -19,5 +19,9 @@ describe('Banner', () => {
expect(wrapper.find(Alert).prop('variant')).toEqual('success');
});
test('renders with custom class', () => {
const wrapper = shallow(<Banner {...props} className="custom-class" />);
expect(wrapper).toMatchSnapshot();
});
});
});

View File

@@ -0,0 +1,16 @@
import { shallow } from 'enzyme';
import EmailLink from './EmailLink';
describe('EmailLink', () => {
it('renders null when no address is provided', () => {
const wrapper = shallow(<EmailLink />);
expect(wrapper).toMatchSnapshot();
expect(wrapper.isEmptyRender()).toEqual(true);
});
it('renders a MailtoLink when an address is provided', () => {
const wrapper = shallow(<EmailLink address="test@email.com" />);
expect(wrapper.find('MailtoLink').length).toEqual(1);
expect(wrapper).toMatchSnapshot();
});
});

View File

@@ -10,6 +10,16 @@ exports[`Banner snapshot renders default banner 1`] = `
</Alert>
`;
exports[`Banner snapshot renders with custom class 1`] = `
<Alert
className="custom-class"
icon={[MockFunction icons.Info]}
variant="info"
>
Hello, world!
</Alert>
`;
exports[`Banner snapshot renders with variants 1`] = `
<Alert
className="mb-0"

View File

@@ -0,0 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`EmailLink renders a MailtoLink when an address is provided 1`] = `
<MailtoLink
to="test@email.com"
>
test@email.com
</MailtoLink>
`;
exports[`EmailLink renders null when no address is provided 1`] = `""`;