parent
ae9db20c92
commit
2e6a26a53e
@ -1,7 +0,0 @@
|
|||||||
/*
|
|
||||||
* Replace this with your own classes
|
|
||||||
*
|
|
||||||
* e.g.
|
|
||||||
* .container {
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
import { render } from '@testing-library/react';
|
|
||||||
|
|
||||||
import HeaderAuth from './header-auth';
|
|
||||||
|
|
||||||
describe('HeaderAuth', () => {
|
|
||||||
it('should render successfully', () => {
|
|
||||||
const { baseElement } = render(<HeaderAuth />);
|
|
||||||
expect(baseElement).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
import styles from './header-auth.module.scss';
|
|
||||||
import {useRouter} from "next/router";
|
|
||||||
|
|
||||||
export function HeaderAuth() {
|
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
const goBack = (event) => {
|
|
||||||
router.back();
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<nav className="bg-white border-gray-200 px-2 sm:px-4 py-2.5 rounded dark:bg-gray-900">
|
|
||||||
<div className="container flex flex-wrap items-center justify-between mx-auto">
|
|
||||||
<div className="flex md:order-2">
|
|
||||||
<button type="button"
|
|
||||||
onClick={(event) => goBack(event)}
|
|
||||||
className="py-2.5 px-5 mr-2 mb-2 text-sm font-medium text-gray-900 focus:outline-none bg-white rounded-lg border border-gray-200 hover:bg-gray-100 hover:text-blue-700 focus:z-10 focus:ring-4 focus:ring-gray-200 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700">
|
|
||||||
Retour au site
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div className="items-center justify-between hidden w-full md:flex md:w-auto md:order-1"
|
|
||||||
id="navbar-sticky"></div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default HeaderAuth;
|
|
||||||
@ -1,10 +1,26 @@
|
|||||||
import { render } from '@testing-library/react';
|
import {render} from '@testing-library/react';
|
||||||
|
import {SessionProvider, useSession} from "next-auth/react";
|
||||||
|
|
||||||
import Header from './header';
|
import Header from './header';
|
||||||
|
|
||||||
|
jest.mock("next-auth/react", () => {
|
||||||
|
const originalModule = jest.requireActual('next-auth/react');
|
||||||
|
const mockSession = {
|
||||||
|
expires: new Date(Date.now() + 2 * 86400).toISOString(),
|
||||||
|
user: { username: "admin" }
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
__esModule: true,
|
||||||
|
...originalModule,
|
||||||
|
useSession: jest.fn(() => {
|
||||||
|
return {data: mockSession, status: 'authenticated'} // return type is [] in v3 but changed to {} in v4
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
describe('Header', () => {
|
describe('Header', () => {
|
||||||
it('should render successfully', () => {
|
it('should render successfully', () => {
|
||||||
const { baseElement } = render(<Header />);
|
const {baseElement} = render(<Header/>);
|
||||||
expect(baseElement).toBeTruthy();
|
expect(baseElement).toBeTruthy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -0,0 +1,26 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import {render} from '@testing-library/react';
|
||||||
|
|
||||||
|
import Index from '../pages/index';
|
||||||
|
|
||||||
|
jest.mock("next-auth/react", () => {
|
||||||
|
const originalModule = jest.requireActual('next-auth/react');
|
||||||
|
const mockSession = {
|
||||||
|
expires: new Date(Date.now() + 2 * 86400).toISOString(),
|
||||||
|
user: {username: "admin"}
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
__esModule: true,
|
||||||
|
...originalModule,
|
||||||
|
useSession: jest.fn(() => {
|
||||||
|
return {data: mockSession, status: 'authenticated'} // return type is [] in v3 but changed to {} in v4
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Index', () => {
|
||||||
|
it('should render successfully', () => {
|
||||||
|
const {baseElement} = render(<Index/>);
|
||||||
|
expect(baseElement).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -1,11 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import { render } from '@testing-library/react';
|
|
||||||
|
|
||||||
import Index from '../pages/index';
|
|
||||||
|
|
||||||
describe('Index', () => {
|
|
||||||
it('should render successfully', () => {
|
|
||||||
const { baseElement } = render(<Index />);
|
|
||||||
expect(baseElement).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
Loading…
Reference in new issue