Files
freeCodeCamp/client/src/components/helpers/link.test.tsx
Nicholas Carrigan (he/him) 592a2846d3 chore: pass CI (#42635)
* chore: eslint on icons

* chore: eslint spacer element

* chore: remove more eslint

* fix: existing lint issues

* fix: misnamed import

* fix: client now builds!

* fix: tsc errors

* fix: more linting issues
2021-06-30 20:52:17 +05:30

27 lines
812 B
TypeScript

/* eslint-disable @typescript-eslint/ban-ts-comment */
import React from 'react';
import { create } from 'react-test-renderer';
import Link from './link';
describe('<Link />', () => {
const externalLink = create(<Link external={true} to='/home' />).toJSON();
const gatsbyLink = create(<Link to='/home' />).toJSON();
it('renders to the DOM', () => {
expect(gatsbyLink).toBeTruthy();
});
it('sets target for external links', () => {
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
expect(externalLink.props.target).toEqual('_blank');
});
it('does not specify target in gatsbyLink', () => {
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
expect(gatsbyLink.props.target).toBeFalsy();
});
});