photon-module.test.ts 656 B

1234567891011121314151617181920
  1. import { describe, expect, it } from "vitest";
  2. import { resolvePhotonModule } from "../src/utils/photon.ts";
  3. describe("resolvePhotonModule", () => {
  4. it("accepts the direct CommonJS export shape", () => {
  5. const photon = { PhotonImage: class PhotonImage {} };
  6. expect(resolvePhotonModule(photon)).toBe(photon);
  7. });
  8. it("unwraps the default export shape produced by split ESM bundles", () => {
  9. const photon = { PhotonImage: class PhotonImage {} };
  10. expect(resolvePhotonModule({ default: photon })).toBe(photon);
  11. });
  12. it("rejects module namespaces without PhotonImage", () => {
  13. expect(resolvePhotonModule({ default: {} })).toBeNull();
  14. });
  15. });