diff --git a/tests/pages/saving/[slug].test.js b/tests/pages/saving/[slug].test.js index 72b5cb6..6c745a3 100644 --- a/tests/pages/saving/[slug].test.js +++ b/tests/pages/saving/[slug].test.js @@ -2,6 +2,7 @@ import SavingSlug from '@/pages/saving/[slug]'; import { render } from '@testing-library/react'; import { TransactionContext } from '@/components/organisms/Transaction'; import { SessionProvider } from 'next-auth/react'; +import DashboardLayout from '../../../layouts/Dashboard'; jest.mock('next/router', () => ({ useRouter: jest.fn().mockReturnValue({ @@ -17,7 +18,7 @@ describe('Saving', () => { const { container } = render( {} }} + value={{ transaction: {}, setTransaction: () => { } }} > @@ -25,4 +26,12 @@ describe('Saving', () => { ); expect(container).toMatchSnapshot(); }); + + it('should use DashboardLayout as layout', () => { + expect(SavingSlug.getLayout(
)).toEqual( + +
+ , + ); + }); }); diff --git a/tests/pages/saving/__snapshots__/done.test.js.snap b/tests/pages/saving/__snapshots__/done.test.js.snap index 62c531c..b181c07 100644 --- a/tests/pages/saving/__snapshots__/done.test.js.snap +++ b/tests/pages/saving/__snapshots__/done.test.js.snap @@ -1,6 +1,12 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Saving should render 1`] = ` +exports[`Saving should render when redirect fails 1`] = ` +
+ Paiement échoué... +
+`; + +exports[`Saving should render when redirect succeeds 1`] = `
({ - useRouter: jest.fn().mockReturnValue({ - query: { - redirect_status: 'succeeded', - }, - }), + useRouter: jest.fn(), })); describe('Saving', () => { - it('should render', () => { + it('should render when redirect succeeds', () => { + useRouter.mockReturnValueOnce({ + query: { + redirect_status: 'succeeded', + }, + }); + + const queryClient = new QueryClient(); + const { container } = render( + + { } }}> + + { } }} + > + + + + + , + ); + expect(container).toMatchSnapshot(); + }); + + it('should render when redirect fails', () => { + useRouter.mockReturnValueOnce({ + query: { + redirect_status: 'failed', + }, + }); + const queryClient = new QueryClient(); const { container } = render( - {} }}> + { } }}> {} }} + value={{ transaction: {}, setTransaction: () => { } }} > @@ -31,4 +59,12 @@ describe('Saving', () => { ); expect(container).toMatchSnapshot(); }); + + it('should use DashboardLayout as layout', () => { + expect(Done.getLayout(
)).toEqual( + +
+ , + ); + }); }); diff --git a/tests/pages/saving/index.test.js b/tests/pages/saving/index.test.js index 26288c7..8407472 100644 --- a/tests/pages/saving/index.test.js +++ b/tests/pages/saving/index.test.js @@ -2,13 +2,14 @@ import Saving from '@/pages/saving'; import { render } from '@testing-library/react'; import { TransactionContext } from '@/components/organisms/Transaction'; import { SessionProvider } from 'next-auth/react'; +import DashboardLayout from '../../../layouts/Dashboard'; describe('Saving', () => { it('should render', () => { const { container } = render( {} }} + value={{ transaction: {}, setTransaction: () => { } }} > @@ -16,4 +17,12 @@ describe('Saving', () => { ); expect(container).toMatchSnapshot(); }); + + it('should use DashboardLayout as layout', () => { + expect(Saving.getLayout(
)).toEqual( + +
+ , + ); + }); }); diff --git a/tests/pages/saving/new.test.js b/tests/pages/saving/new.test.js index 0eec72c..9fc4d97 100644 --- a/tests/pages/saving/new.test.js +++ b/tests/pages/saving/new.test.js @@ -4,6 +4,7 @@ import { TransactionContext } from '@/components/organisms/Transaction'; import { SessionProvider } from 'next-auth/react'; import { DrawContext } from '../../../pages/_app'; import { QueryClientProvider, QueryClient } from 'react-query'; +import DashboardLayout from '../../../layouts/Dashboard'; jest.mock('next/router', () => ({ useRouter: jest.fn().mockReturnValue({ @@ -16,10 +17,10 @@ describe('Saving', () => { const queryClient = new QueryClient(); const { container } = render( - {} }}> + { } }}> {} }} + value={{ transaction: {}, setTransaction: () => { } }} > @@ -29,4 +30,12 @@ describe('Saving', () => { ); expect(container).toMatchSnapshot(); }); + + it('should use DashboardLayout as layout', () => { + expect(NewSaving.getLayout(
)).toEqual( + +
+ , + ); + }); }); diff --git a/tests/pages/saving/operation/[saving].test.js b/tests/pages/saving/operation/[saving].test.js index eb230b3..e85b8f2 100644 --- a/tests/pages/saving/operation/[saving].test.js +++ b/tests/pages/saving/operation/[saving].test.js @@ -2,6 +2,7 @@ import { render, screen } from "@testing-library/react"; import Page from "@/pages/saving/operation/[saving]"; import { SessionProvider } from "next-auth/react"; import { QueryClient, QueryClientProvider } from "react-query"; +import DashboardLayout from "../../../../layouts/Dashboard"; jest.mock('next/router', () => ({ useRouter: jest.fn().mockReturnValue({ @@ -28,4 +29,12 @@ describe("Page", () => { const pageTitle = screen.getAllByText("Récharger mon épargne"); expect(pageTitle).toHaveLength(2); }); + + it('should use DashboardLayout as layout', () => { + expect(Page.getLayout(
)).toEqual( + +
+ , + ); + }); }); \ No newline at end of file diff --git a/tests/pages/saving/summary.test.js b/tests/pages/saving/summary.test.js index 8260e0f..d201015 100644 --- a/tests/pages/saving/summary.test.js +++ b/tests/pages/saving/summary.test.js @@ -4,6 +4,7 @@ import { TransactionContext } from '@/components/organisms/Transaction'; import { SessionProvider } from 'next-auth/react'; import { DrawContext } from '../../../pages/_app'; import { QueryClientProvider, QueryClient } from 'react-query'; +import DashboardLayout from '../../../layouts/Dashboard'; require('jest-fetch-mock').enableMocks(); @@ -24,13 +25,13 @@ describe('Saving Summary', () => { {}, + setDraw: () => { }, saving: { plan: { currency: 'GBP' }, target: { currency: 'USD' } }, }} > {} }} + value={{ transaction: {}, setTransaction: () => { } }} > @@ -41,4 +42,12 @@ describe('Saving Summary', () => { ); expect(container).toMatchSnapshot(); }); + + it('should use DashboardLayout as layout', () => { + expect(SavingSummary.getLayout(
)).toEqual( + +
+ , + ); + }); });