Unregistered.spec.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * Copyright 2021-2024 Avaiga Private Limited
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
  5. * the License. You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  10. * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
  11. * specific language governing permissions and limitations under the License.
  12. */
  13. import { render, screen } from "@testing-library/react";
  14. import "@testing-library/jest-dom";
  15. import { renderError, unregisteredRender } from "./Unregistered";
  16. describe("Unregistered component", () => {
  17. it('should display "component is not registered" when tagName is provided', () => {
  18. render(unregisteredRender("TestComponent"));
  19. expect(screen.getByText("Component TestComponent is not registered")).toBeInTheDocument();
  20. });
  21. it("should display error message when tagName is not provided", () => {
  22. render(unregisteredRender(undefined, "TestError"));
  23. expect(screen.getByText("An Error occurred: TestError")).toBeInTheDocument();
  24. });
  25. it("should display error message when there is an error", () => {
  26. render(renderError({ error: "TestError" }));
  27. expect(screen.getByText("An Error occurred: TestError")).toBeInTheDocument();
  28. });
  29. });