() => { const wrapper = shallow( <ButtonExternalLink url={testUrl}>{linkText}</ButtonExternalLink> ) it('renders a link element', () => { expect(wrapper.find('a')).toHaveLength(1) }) it('renders a link with a given url', () => { expect(wrapper.find('a').prop('href')).toEqual(testUrl) }) it('renders a link with a class', () => { expect(wrapper.hasClass('btn')).toBe(true) }) }) describe('renders a link with a given content', () => { it('renders a link with a text as children', () => { const wrapper = shallow( <ButtonExternalLink url={testUrl}>{linkText}</ButtonExternalLink> ) expect(wrapper.text()).toBe(linkText) }) it('renders a link with an image as children', () => { const wrapper = shallow( <ButtonExternalLink url={testUrl}>{linkImage}</ButtonExternalLink> ) expect(wrapper.contains(linkImage)).toBe(true) }) }) describe('can style specific looks "primary" and "secondary"', () => { it('adds a class for style primary', () => { const wrapper = shallow( <ButtonExternalLink url={testUrl} primary> {linkText} </ButtonExternalLink> ) expect(wrapper.hasClass('btn-primary')).toBe(true) expect(wrapper.hasClass('btn-secondary')).toBe(false) }) it('adds a class for style secondary', () => { const wrapper = shallow( <ButtonExternalLink url={testUrl} secondary> {linkText} </ButtonExternalLink> ) expect(wrapper.hasClass('btn-secondary')).toBe(true) expect(wrapper.hasClass('btn-primary')).toBe(false) }) })