Advertisement
Guest User

Untitled

a guest
Dec 16th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from "react";
  2.  
  3. import NextPages from "./NextPages.js";
  4. import Page from "../Page/Page.js";
  5.  
  6. const exampleLinkFactory = () => (
  7.   <a href={`#`} />
  8. );
  9.  
  10. describe("Pagination/NextPages", () => {
  11.   rendersComponent(NextPages);
  12.  
  13.   const wrapper = mount(
  14.     <NextPages />
  15.   );
  16.  
  17.   it("doesn\'t render a Page component", () => {
  18.     expect(wrapper.find(Page).exists()).toEqual(false);
  19.   });
  20.  
  21.   describe("when the current page is not the last page", () => {
  22.     const customProps = {
  23.       page: 2,
  24.       totalPages: 4,
  25.       linkFactory: exampleLinkFactory
  26.     };
  27.  
  28.     rendersComponent(NextPages, customProps);
  29.  
  30.     const wrapper = mount(
  31.       <NextPages { ...customProps } />
  32.     );
  33.  
  34.     it("renders two Page components", () => {
  35.       expect(wrapper.find(Page).length).toEqual(2);
  36.     });
  37.   });
  38.  
  39.   describe("when the current page is the second to last page", () => {
  40.     const customProps = {
  41.       page: 3,
  42.       totalPages: 4,
  43.       linkFactory: exampleLinkFactory
  44.     };
  45.  
  46.     rendersComponent(NextPages, customProps);
  47.  
  48.     const wrapper = mount(
  49.       <NextPages { ...customProps } />
  50.     );
  51.  
  52.     it("renders two Page components", () => {
  53.       expect(wrapper.find(Page).length).toEqual(2);
  54.     });
  55.   });
  56.  
  57.   describe("when the current page is the last page", () => {
  58.     const customProps = {
  59.       page: 4,
  60.       totalPages: 4,
  61.       linkFactory: exampleLinkFactory
  62.     };
  63.  
  64.     rendersComponent(NextPages, customProps);
  65.  
  66.     const wrapper = mount(
  67.       <NextPages { ...customProps } />
  68.     );
  69.  
  70.     it("doesn\'t render a Page component", () => {
  71.       expect(wrapper.find(Page).exists()).toEqual(false);
  72.     });
  73.   });
  74. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement