diff --git a/.github/workflows/build-tests.yml b/.github/workflows/build-tests.yml index 4fcc7e9..065d463 100644 --- a/.github/workflows/build-tests.yml +++ b/.github/workflows/build-tests.yml @@ -1,8 +1,6 @@ name: build-tests on: pull_request: - branches: - - dev jobs: unit-testing: runs-on: ubuntu-latest diff --git a/client/src/pages/DirectoryPage/DirectoryPage.test.tsx b/client/src/pages/DirectoryPage/DirectoryPage.test.tsx new file mode 100644 index 0000000..a25e459 --- /dev/null +++ b/client/src/pages/DirectoryPage/DirectoryPage.test.tsx @@ -0,0 +1,31 @@ +import React from "react"; +import { create } from "react-test-renderer"; +import { Provider } from "react-redux"; +import configureStore from "redux-mock-store"; + +import DirectoryPage from "./DirectoryPage"; + +interface State { + user: { + userName: string; + }; +} + +const mockStore = configureStore([]); +const initialState: State = { + user: { + userName: "TEST", + }, +}; + +describe("MainPage Component", () => { + it("renders correctly", () => { + const store = mockStore(initialState); + const tree = create( + + + + ).toJSON(); + expect(tree).toMatchSnapshot(); + }); +}); diff --git a/client/src/pages/DirectoryPage/DirectoryPage.tsx b/client/src/pages/DirectoryPage/DirectoryPage.tsx new file mode 100644 index 0000000..df7ac50 --- /dev/null +++ b/client/src/pages/DirectoryPage/DirectoryPage.tsx @@ -0,0 +1,15 @@ +import React from "react"; +import { useAppSelector } from "../../app/hooks"; + +const DirectoryPage = (): JSX.Element => { + const user = useAppSelector((state) => state.user.userData); + + return ( +
+

Directory Page

+

Welcome {user?.firstName} !

+
+ ); +}; + +export default DirectoryPage; diff --git a/client/src/pages/DirectoryPage/__snapshots__/DirectoryPage.test.tsx.snap b/client/src/pages/DirectoryPage/__snapshots__/DirectoryPage.test.tsx.snap new file mode 100644 index 0000000..ac10b89 --- /dev/null +++ b/client/src/pages/DirectoryPage/__snapshots__/DirectoryPage.test.tsx.snap @@ -0,0 +1,17 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`MainPage Component renders correctly 1`] = ` +
+

+ Directory Page +

+

+ Welcome + ! +

+
+`;