Sha256: f9fb855737e01e0f7655558af6a2b97874ac52b21a0595f5972b0e22843f005d
Contents?: true
Size: 1.98 KB
Versions: 2
Compression:
Stored size: 1.98 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 generateUserData from "../support/generate_user_data"; import { UpVoteButtonFragment } from "../support/schema"; describe("<UpVoteButton />", () => { let comment: UpVoteButtonFragment; let session: any = null; const upVote = jasmine.createSpy("upVote"); beforeEach(() => { const commentsData = generateCommentsData(1); session = { user: generateUserData(), }; comment = commentsData[0]; }); it("should render a VoteButton component with the correct props", () => { const wrapper = shallow(<UpVoteButton session={session} 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 session={session} 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 session={session} comment={comment} upVote={upVote} />); expect(wrapper.find(VoteButton).prop("disabled")).toBeTruthy(); }); describe("when session is not present", () => { beforeEach(() => { session = null; }); it("should pass userLoggedIn as false", () => { const wrapper = shallow(<UpVoteButton session={session} comment={comment} upVote={upVote} />); expect(wrapper.find(VoteButton).prop("userLoggedIn")).toBeFalsy(); }); }); });
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
decidim-comments-0.3.2 | app/frontend/comments/up_vote_button.component.test.tsx |
decidim-0.3.2 | decidim-comments/app/frontend/comments/up_vote_button.component.test.tsx |