diff --git a/src/components/__tests__/NavBar.test b/src/components/__tests__/NavBar.test deleted file mode 100644 index 52c4d01..0000000 --- a/src/components/__tests__/NavBar.test +++ /dev/null @@ -1,93 +0,0 @@ -// import React from 'react'; -// import NavBar from '../NavBar'; -// import {render, RenderResult} from '@testing-library/react'; - -// describe('Navbar displays', () => { -// let context: RenderResult; - -// let navProps = { -// isAuthenticated: false, -// loading: true, -// }; - -// beforeEach(() => { -// context = render(); -// }); - -// test('landing page link', () => { -// const {getAllByTestId} = context; -// const link = getAllByTestId('homeLink'); -// expect(link[0]).toBeTruthy(); -// }); - -// it('no links while loading', () => { -// const {queryByTestId} = context; -// const links = queryByTestId('privateLinks'); -// expect(links).toBeNull(); -// }); - -// describe('when loaded', () => { -// describe('when user is not authenticated', () => { -// navProps = { -// isAuthenticated: false, -// loading: false, -// }; - -// beforeEach(() => { -// context = render(); -// }); - -// test('developers link', () => { -// const {getAllByTestId} = context; -// const link = getAllByTestId('devsLink'); -// expect(link[0]).toBeTruthy(); -// }); - -// test('register link', () => { -// const {getAllByTestId} = context; -// const link = getAllByTestId('signupLink'); -// expect(link[0]).toBeTruthy(); -// }); -// test('login page link', () => { -// const {getAllByTestId} = context; -// const link = getAllByTestId('loginLink'); -// expect(link[0]).toBeTruthy(); -// }); -// }); - -// describe('when user is authenticated', () => { -// navProps = { -// isAuthenticated: true, -// loading: false, -// }; - -// beforeEach(() => { -// context = render(); -// }); - -// test('developers link', () => { -// const {getAllByTestId} = context; -// const link = getAllByTestId('devsLink'); -// expect(link[0]).toBeTruthy(); -// }); - -// test('posts page link', () => { -// const {getAllByTestId} = context; -// const link = getAllByTestId('postsLink'); -// expect(link[0]).toBeTruthy(); -// }); - -// test('dashboard page link', () => { -// const {getAllByTestId} = context; -// const link = getAllByTestId('dashboardLink'); -// expect(link[0]).toBeTruthy(); -// }); - -// test('logout page link', () => { -// const {getAllByTestId} = context; -// const link = getAllByTestId('logoutLink'); -// expect(link[0]).toBeTruthy(); -// }); -// }); -// }); -// }); diff --git a/src/components/__tests__/NavBar.test.tsx b/src/components/__tests__/NavBar.test.tsx new file mode 100644 index 0000000..b041e36 --- /dev/null +++ b/src/components/__tests__/NavBar.test.tsx @@ -0,0 +1,110 @@ +import React from 'react'; +import {BrowserRouter} from 'react-router-dom'; +import NavBar from '../NavBar'; +import {render, RenderResult} from '@testing-library/react'; + +interface IProps { + isAuthenticated: boolean; + loading: boolean; +} +describe('Navbar displays', () => { + let context: RenderResult; + let navProps: IProps; + + describe('before loading', () => { + navProps = { + isAuthenticated: false, + loading: true, + }; + + beforeEach(() => { + context = render( + + + , + ); + }); + + test('landing page link', () => { + const {getAllByTestId} = context; + const link = getAllByTestId('homeLink'); + expect(link[0]).toBeTruthy(); + }); + + it('no links while loading', () => { + const {queryByTestId} = context; + const links = queryByTestId('privateLinks'); + expect(links).toBeNull(); + }); + }); + + describe('when loaded', () => { + describe('when user is not authenticated', () => { + navProps = { + isAuthenticated: false, + loading: false, + }; + + beforeEach(() => { + context = render( + + + , + ); + }); + + test('developers link', () => { + const {getAllByTestId} = context; + const link = getAllByTestId('devsLink'); + expect(link[0]).toBeTruthy(); + }); + + test('register link', () => { + const {getAllByTestId} = context; + const link = getAllByTestId('signupLink'); + expect(link[0]).toBeTruthy(); + }); + + test('login page link', () => { + const {getAllByTestId} = context; + const link = getAllByTestId('loginLink'); + expect(link[0]).toBeTruthy(); + }); + }); + + // describe('when user is authenticated', () => { + // navProps = { + // isAuthenticated: true, + // loading: false, + // }; + // beforeEach(() => { + // context = render( + // + // + // , + // ); + // }); + // test('developers link', () => { + // const {getAllByTestId} = context; + // const link = getAllByTestId('devsLink'); + // expect(link[0]).toBeTruthy(); + // }); + // // test('posts page link', () => { + // // const {getAllByTestId} = context; + // // const link = getAllByTestId('postsLink'); + // // expect(link[0]).toBeTruthy(); + // // }); + // // test('dashboard page link', () => { + // // const {getAllByTestId} = context; + // // const link = getAllByTestId('dashboardLink'); + // // expect(link[0]).toBeTruthy(); + // // }); + // // test('logout page link', () => { + // // const {getAllByTestId} = context; + // // const link = getAllByTestId('logoutLink'); + // // expect(link[0]).toBeTruthy(); + // // }); + // // }); + // }); + }); +});