import { shallow, mount } from 'enzyme';
import React from 'react';
import { NavbarLogo } from 'web-foundation';

describe('<NavbarLogo />', function() {
    it('should initialize all nice like', function() {
        const wrapper = mount(
            <NavbarLogo />
        );

        expect(wrapper.type()).to.equal(NavbarLogo);
    });

    it('should have component class name', function() {
        const wrapper = shallow(<NavbarLogo />);

        expect(wrapper.hasClass('navbar-logo')).to.be.true;
    });

    it('should trigger callback if click prop is a function', function() {
        const spy = sinon.spy(),
            wrapper = shallow(<NavbarLogo click={ spy } />);

        wrapper.find('a').simulate('click');

        expect(spy.calledOnce).to.be.true;
    });

    it('should use href if click prop is a string', function() {
        const path = '/path',
            wrapper = shallow(<NavbarLogo click={ path } />);

        expect(wrapper.find('a').props().href).to.equal(path);
    });

    it('should use title prop in content', function() {
        const title = 'My Link',
            wrapper = shallow(<NavbarLogo click="/path"
                title={ title } />);

        expect(wrapper.find('a').props().title).to.equal(title);
        expect(wrapper.find('img').props().alt).to.equal(title);
    });
});
