footer.test.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import React from "react";
  2. import { render } from "@testing-library/react";
  3. import { StoreProvider } from "easy-peasy";
  4. import { initializeStore } from "../../store";
  5. import Footer from "../Footer";
  6. import getConfig from "next/config";
  7. describe("<Footer /> component test", () => {
  8. let app;
  9. beforeEach(() => {
  10. const store = initializeStore();
  11. app = (
  12. <StoreProvider store={store}>
  13. <Footer />
  14. </StoreProvider>
  15. );
  16. });
  17. it("should contain a github link", () => {
  18. const screen = render(app);
  19. const githubLink = screen.getByRole("link", { name: "GitHub" });
  20. expect(githubLink).toHaveAttribute("href", "https://github.com/thedevs-network/kutt");
  21. });
  22. it("should contain a TOS link", () => {
  23. const config = getConfig();
  24. const screen = render(app);
  25. const tosLink = screen.getByRole("link", { name: "Terms of Service" });
  26. expect(tosLink).toHaveAttribute("href", "/terms");
  27. });
  28. it("should show contact email if defined", () => {
  29. const config = getConfig();
  30. config.publicRuntimeConfig.CONTACT_EMAIL = 'foobar';
  31. const screen = render(app);
  32. const emailLink = screen.getByRole("link", { name: "Contact us" });
  33. expect(emailLink).toHaveAttribute("href", "mailto:foobar");
  34. });
  35. it("should NOT show contact email if none is defined", () => {
  36. const config = getConfig();
  37. delete(config.publicRuntimeConfig.CONTACT_EMAIL);
  38. const screen = render(app);
  39. const emailLink= screen.queryByRole("link", { name: "Contact us" });
  40. expect(emailLink).toBeNull();
  41. });
  42. })