Sha256: 40a9343d2bf92b078248cd99bf51c360feaa4605acf7294770c7fea437a5bb03

Contents?: true

Size: 1.46 KB

Versions: 4

Compression:

Stored size: 1.46 KB

Contents

import { shallow }          from "enzyme";
import * as React from "react";

import { UpVoteButton }     from "./up_vote_button.component";
import VoteButton           from "./vote_button.component";

import generateCommentsData from "../support/generate_comments_data";

import { UpVoteFragment } from "../support/schema";

describe("<UpVoteButton />", () => {
  let comment: UpVoteFragment;
  const upVote = jasmine.createSpy("upVote");

  beforeEach(() => {
    let commentsData = generateCommentsData(1);

    comment = commentsData[0];
  });

  it("should render a VoteButton component with the correct props", () => {
    const wrapper = shallow(<UpVoteButton comment={comment} upVote={upVote} />);
    expect(wrapper.find(VoteButton).prop("buttonClassName")).toEqual("comment__votes--up");
    expect(wrapper.find(VoteButton).prop("iconName")).toEqual("icon-chevron-top");
    expect(wrapper.find(VoteButton).prop("votes")).toEqual(comment.upVotes);
  });

  it("should pass disabled prop as true if comment upVoted is true", () => {
    comment.upVoted = true;
    const wrapper = shallow(<UpVoteButton comment={comment} upVote={upVote} />);
    expect(wrapper.find(VoteButton).prop("disabled")).toBeTruthy();
  });

  it("should pass disabled prop as true if comment downVoted is true", () => {
    comment.downVoted = true;
    const wrapper = shallow(<UpVoteButton comment={comment} upVote={upVote} />);
    expect(wrapper.find(VoteButton).prop("disabled")).toBeTruthy();
  });
});

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
decidim-comments-0.0.8.1 app/frontend/comments/up_vote_button.component.test.tsx
decidim-0.0.8.1 decidim-comments/app/frontend/comments/up_vote_button.component.test.tsx
decidim-comments-0.0.7 app/frontend/comments/up_vote_button.component.test.tsx
decidim-0.0.7 decidim-comments/app/frontend/comments/up_vote_button.component.test.tsx