/* global jest, expect, describe, it, afterEach */ import * as React from 'react' import { ThemeProvider } from 'styled-components' import { shallow } from 'enzyme' import { create } from 'react-test-renderer' import Anchor, { AnchorProps } from '../anchor' describe('anchor tests', () => { describe('basic tests', () => { it('matches the snapshot', () => { const component = const tree = create(component).toJSON() expect(tree).toMatchSnapshot() }) it('renders the component', () => { const wrapper = shallow() const assertion = wrapper.find('#anchor').length expect(assertion).toBe(1) }) }) describe('component behavior', () => { it('defines a href', () => { const wrapper = shallow() const assertion = wrapper.props().href expect(assertion).toEqual('https://nespresso.com') }) it('defines a target', () => { const wrapper = shallow() const assertion = wrapper.props().target expect(assertion).toEqual('_blank') }) it('rel defaults to noreferrer noopener', () => { const wrapper = shallow() const assertion = wrapper.props().rel expect(assertion).toEqual('noreferrer noopener') }) it('can pass text', () => { const wrapper = shallow() const assertion = wrapper.html().includes('GOTCHA') expect(assertion).toBe(true) }) }) describe('theming', () => { it('allows theming the `textDecoration` property', () => { const component = const tree = create(component).toJSON() expect(tree).toHaveStyleRule('text-decoration', 'underline') }) it('allows theming the `color` property', () => { const component = const tree = create(component).toJSON() expect(tree).toHaveStyleRule('color', 'brown') }) it('allows theming the `fontSize` property', () => { const component = const tree = create(component).toJSON() expect(tree).toHaveStyleRule('font-size', '300px') }) it('allows theming the `user-select` property', () => { const component = const tree = create(component).toJSON() expect(tree).toHaveStyleRule('user-select', 'none') }) }) })