Sha256: 256b1e6cccb52d4eee22e957ecb07d132ffd8450f2d1d4fdcfad9f3638785ef4

Contents?: true

Size: 1.08 KB

Versions: 14

Compression:

Stored size: 1.08 KB

Contents

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

import CommentOrderSelector from "./comment_order_selector.component";

describe("<CommentOrderSelector />", () => {
  const orderBy = "older";
  const reorderComments = jasmine.createSpy("reorderComments");

  beforeEach(() => {
    window.$ = () => {
      return {
        foundation: jasmine.createSpy(""),
      };
    };
  });

  it("renders a div with classes order-by__dropdown order-by__dropdown--right", () => {
    const wrapper = shallow(<CommentOrderSelector reorderComments={reorderComments} defaultOrderBy={orderBy} />);
    expect(wrapper.find("div.order-by__dropdown.order-by__dropdown--right")).toBeDefined();
  });

  it("should set state order to best_rated if user clicks on the first element", () => {
      const preventDefault = jasmine.createSpy("preventDefault");
      const wrapper = shallow(<CommentOrderSelector reorderComments={reorderComments} defaultOrderBy={orderBy} />);
      wrapper.find("a.test").simulate("click", {preventDefault});
      expect(reorderComments).toBeCalledWith("best_rated");
    });
});

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
decidim-comments-0.9.3 app/frontend/comments/comment_order_selector.component.test.tsx
decidim-comments-0.9.2 app/frontend/comments/comment_order_selector.component.test.tsx
decidim-comments-0.9.1 app/frontend/comments/comment_order_selector.component.test.tsx
decidim-comments-0.9.0 app/frontend/comments/comment_order_selector.component.test.tsx
decidim-comments-0.8.4 app/frontend/comments/comment_order_selector.component.test.tsx
decidim-comments-0.8.3 app/frontend/comments/comment_order_selector.component.test.tsx
decidim-comments-0.8.2 app/frontend/comments/comment_order_selector.component.test.tsx
decidim-comments-0.8.1 app/frontend/comments/comment_order_selector.component.test.tsx
decidim-comments-0.8.0 app/frontend/comments/comment_order_selector.component.test.tsx
decidim-comments-0.7.4 app/frontend/comments/comment_order_selector.component.test.tsx
decidim-comments-0.7.3 app/frontend/comments/comment_order_selector.component.test.tsx
decidim-comments-0.7.2 app/frontend/comments/comment_order_selector.component.test.tsx
decidim-comments-0.7.1 app/frontend/comments/comment_order_selector.component.test.tsx
decidim-comments-0.7.0 app/frontend/comments/comment_order_selector.component.test.tsx