renderer.test.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { describe, it, expect } from "vitest";
  2. import { Renderer } from "./renderer";
  3. describe("Renderer", () => {
  4. it("is a valid component function", () => {
  5. expect(typeof Renderer).toBe("function");
  6. });
  7. it("accepts null spec", () => {
  8. const props = {
  9. spec: null,
  10. registry: {},
  11. };
  12. expect(props.spec).toBeNull();
  13. expect(props.registry).toEqual({});
  14. });
  15. it("accepts spec without root", () => {
  16. const props = {
  17. spec: { root: "", elements: {} },
  18. registry: {},
  19. };
  20. expect(props.spec.root).toBe("");
  21. expect(props.spec.elements).toEqual({});
  22. });
  23. it("accepts loading prop", () => {
  24. const props = {
  25. spec: null,
  26. registry: {},
  27. loading: true,
  28. };
  29. expect(props.loading).toBe(true);
  30. });
  31. it("accepts fallback prop", () => {
  32. const Fallback = () => {
  33. const el = document.createElement("div");
  34. el.textContent = "Unknown component";
  35. return el;
  36. };
  37. const props = {
  38. spec: null,
  39. registry: {},
  40. fallback: Fallback,
  41. };
  42. expect(props.fallback).toBe(Fallback);
  43. });
  44. });