Sha256: 11c4bc3a9ca3bdba75301749cc86eea87b1b85d040437cdc64ea2192059b9b18

Contents?: true

Size: 1.67 KB

Versions: 2

Compression:

Stored size: 1.67 KB

Contents

/* eslint-disable no-unused-expressions */
import { shallow } from 'enzyme';

import VoteButton  from './vote_button.component';
import Icon        from '../application/icon.component';

import stubComponent from '../support/stub_component';

describe("<VoteButton />", () => {
  const voteAction = sinon.spy();
  stubComponent(Icon);

  it("should render the number of votes passed as a prop", () => {
    const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" voteAction={voteAction} />);
    expect(wrapper.find('button')).to.include.text(10);
  });

  it("should render a button with the given buttonClassName", () => {
    const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" voteAction={voteAction} />);
    expect(wrapper.find('button.vote-button')).to.be.present();
  });

  it("should render a Icon component with the correct name prop", () => {
    const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" voteAction={voteAction} />); 
    expect(wrapper.find(Icon)).to.have.prop("name").equal('vote-icon');
  });

  it("should call the voteAction prop on click", () => {
    const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" voteAction={voteAction} />);
    wrapper.find('button').simulate('click');
    expect(voteAction).to.have.been.called;
  });

  it("should disable the button based on the disabled prop", () => {
    const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" voteAction={voteAction} disabled />);    
    expect(wrapper.find('button')).to.be.disabled();
  })
});

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
decidim-comments-0.0.2 app/frontend/comments/vote_button_component.test.jsx
decidim-0.0.2 decidim-comments/app/frontend/comments/vote_button_component.test.jsx