diff --git a/.gitignore b/.gitignore index 43c8d7e..3a90445 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /dist/ /node_modules/ +/coverage *storybook.log diff --git a/jest.config.js b/jest.config.js index 9b4641d..a6b29cf 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,3 +1,6 @@ module.exports = { testEnvironment: "jsdom", + moduleNameMapper: { + '^.+.(svg)$': 'jest-transform-stub', + } }; \ No newline at end of file diff --git a/package.json b/package.json index 6f80b03..201da1d 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "lint": "eslint .", "rollup": "rollup --config rollup.config.mjs", "jest": "jest --config jest.config.js", + "jest:coverage": "jest --coverage", "storybook": "storybook dev -p 6006", "storybook:build": "storybook build -o storybook-static", "storybook:publish": "gh-pages -b storybook/publish -d storybook-static" @@ -22,21 +23,17 @@ "types": "dist/index.d.ts", "dependencies": { "@mui/icons-material": "^6.1.7", + "jest-transform-stub": "^2.0.0", "react-icons": "^5.3.0" }, "peerDependencies": { - "react": "^18.3.1", - "react-dom": "^18.3.1", - "@mui/material": "^6.1.7", "@emotion/react": "^11.13.3", - "@emotion/styled": "^11.13.0" + "@emotion/styled": "^11.13.0", + "@mui/material": "^6.1.7", + "react": "^18.3.1", + "react-dom": "^18.3.1" }, "devDependencies": { - "react": "^18.3.1", - "react-dom": "^18.3.1", - "@mui/material": "^6.1.7", - "@emotion/react": "^11.13.3", - "@emotion/styled": "^11.13.0", "@babel/core": "^7.26.0", "@babel/preset-env": "^7.26.0", "@babel/preset-react": "^7.25.9", @@ -78,8 +75,7 @@ "storybook-dark-mode": "^4.0.2", "tslib": "^2.8.1", "typescript": "^5.6.3", - "typescript-eslint": "^8.15.0", - "@testing-library/jest-dom": "^6.6.3" + "typescript-eslint": "^8.15.0" }, "packageManager": "pnpm@9.12.3+sha256.24235772cc4ac82a62627cd47f834c72667a2ce87799a846ec4e8e555e2d4b8b" } diff --git a/src/components/Footer.stories.tsx b/src/components/Footer.stories.tsx new file mode 100644 index 0000000..5378e45 --- /dev/null +++ b/src/components/Footer.stories.tsx @@ -0,0 +1,56 @@ +import { Meta, StoryObj } from "@storybook/react/*"; +import { Footer, FooterLink, FooterLinks } from "./Footer"; + +const meta: Meta = { + title: "SciReactUI/Navigation/Footer", + component: Footer, + decorators: [(Story) => ], + tags: ["autodocs"], +}; + +export default meta; +type Story = StoryObj; + +export const LogoOnly: Story = { + args: {}, +}; + +export const CopyrightOnly: Story = { + args: { + logo: "", + copyright: "Company", + }, +}; + +export const CopyrightAndLogo: Story = { + args: { copyright: "Company" }, +}; + +export const WithOneLink: Story = { + args: { + copyright: "Company", + children: [ + + + Link one + + , + ], + }, +}; + +export const WithTwoLinks: Story = { + args: { + copyright: "Company", + children: [ + + + Link one + + + Link two + + , + ], + }, +}; diff --git a/src/components/Footer.test.tsx b/src/components/Footer.test.tsx new file mode 100644 index 0000000..c58e882 --- /dev/null +++ b/src/components/Footer.test.tsx @@ -0,0 +1,88 @@ +import { render, screen, waitFor } from "@testing-library/react"; +import "@testing-library/jest-dom"; + +import dlsLogo from "../public/dls.svg"; + +import { Footer, FooterLink, FooterLinks } from "./Footer"; +describe("Footer", () => { + test("Should render logo only", async () => { + render(