Slide 32
Slide 32 text
describe('renders a link with an url and the "btn" class', () => {
const wrapper = shallow(
{linkText}
)
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(
{linkText}
)
expect(wrapper.text()).toBe(linkText)
})
it('renders a link with an image as children', () => {
const wrapper = shallow(
{linkImage}
)
expect(wrapper.contains(linkImage)).toBe(true)
})
})
describe('can style specific looks "primary" and "secondary"', () => {
it('adds a class for style primary', () => {
const wrapper = shallow(
{linkText}
)
expect(wrapper.hasClass('btn-primary')).toBe(true)
expect(wrapper.hasClass('btn-secondary')).toBe(false)
})
it('adds a class for style secondary', () => {
const wrapper = shallow(
{linkText}
)
expect(wrapper.hasClass('btn-secondary')).toBe(true)
expect(wrapper.hasClass('btn-primary')).toBe(false)
})
})