Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. it(`flows between All Clients and Client Detail pages`, async () => {
  2.  
  3. // setup component and mock api calls
  4. const clientsList = MockApiData.successData([
  5. MockApiData.partialClientData({
  6. client_first_name: "Sammy",
  7. partner_first_name: "David",
  8. upcoming_shoot_date: "2020-07-17T14:00:00Z",
  9. uuid: client_uuid
  10. }),
  11. MockApiData.partialClientData({
  12. uuid: "0000",
  13. client_first_name: "Natasha",
  14. partner_first_name: "Zihao",
  15. package_name: "Wedding Classic",
  16. upcoming_shoot_date: "2020-09-17T14:00:00Z",
  17. current_stage: MockApiData.taskData({
  18. category: "Proposal & Retainer",
  19. step: "Confirm Proposal & Retainer"
  20. })
  21. })
  22. ])
  23. const client = MockApiData.successData(
  24. MockApiData.allClientData({ uuid: client_uuid })
  25. )
  26. const apiHandler = new MockAPIHandler({
  27. [Endpoints.getClients(user_uuid)]: [clientsList],
  28. [Endpoints.getClient(client_uuid)]: [client]
  29. });
  30.  
  31. let component;
  32.  
  33. // mounts the entire application as we are testing the flow between 2 pages
  34. await act(async () => {
  35. component = render(
  36. <MemoryRouter initialEntries={["/clients"]} initialIndex={0}>
  37. <App apiHandler={apiHandler} authUser={authUser}/>
  38. </MemoryRouter>
  39. )
  40. })
  41.  
  42. const { findByText, getByText, getAllByText } = component;
  43.  
  44. // asserts expected text to be found on All Clients Page
  45. await waitForElement(() =>
  46. findByText(/Sammy & David/i)
  47. )
  48.  
  49. getByText(/Wedding Premier/i)
  50. getByText(/July 17, 2020/i)
  51. getByText(/New Client Inquiry/i)
  52. getByText(/Request More Information/i)
  53.  
  54. getByText(/Natasha & Zihao/i)
  55. getByText(/September 17, 2020/i)
  56. getByText(/Confirm Proposal & Retainer/i)
  57.  
  58. // Clicking the View button to navigate to a client detail page
  59. await act(async () => {
  60. fireEvent.click(getAllByText("View")[0]);
  61. })
  62.  
  63. // asserts expected text to be found on the Client Detail Page
  64. await waitForElement(() =>
  65. findByText(/sammy lee/i)
  66. )
  67. getByText(/client information/i)
  68. getAllByText(/package/i)
  69. getAllByText(/new client inquiry/i)
  70. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement