From d4b83965e3068b5ec99d6080b4a9645bd23a2d42 Mon Sep 17 00:00:00 2001 From: Sean Date: Tue, 9 Jan 2024 05:20:14 -0500 Subject: [PATCH 1/2] Added basic direxctory page and snapshot test --- .../DirectoryPage/DirectoryPage.test.tsx | 31 +++++++++++++++++++ .../src/pages/DirectoryPage/DirectoryPage.tsx | 15 +++++++++ .../__snapshots__/DirectoryPage.test.tsx.snap | 17 ++++++++++ 3 files changed, 63 insertions(+) create mode 100644 client/src/pages/DirectoryPage/DirectoryPage.test.tsx create mode 100644 client/src/pages/DirectoryPage/DirectoryPage.tsx create mode 100644 client/src/pages/DirectoryPage/__snapshots__/DirectoryPage.test.tsx.snap 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 + ! +

+
+`; From e263ab66343b2908047a93f45990f02151a026c2 Mon Sep 17 00:00:00 2001 From: Sean Date: Sat, 13 Jan 2024 11:43:24 -0500 Subject: [PATCH 2/2] CHE-16 adjustment made to GH workflow script --- .github/workflows/build-tests.yml | 2 -- 1 file changed, 2 deletions(-) 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