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

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

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

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

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

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

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

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

    it('should not die if no callback is given', function() {
        const spy = sinon.spy(),
            wrapper = shallow(<NavbarButton />);

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

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

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

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

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

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

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

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