Initial Commit
This commit is contained in:
46
packages/ui/react/react-audio-player/tests/exports.test.ts
Normal file
46
packages/ui/react/react-audio-player/tests/exports.test.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { join, resolve } from "node:path";
|
||||
import { describe, expect, it } from "@suaveplan/testing/runner";
|
||||
|
||||
const PKG_ROOT = resolve(__dirname, "..");
|
||||
const PKG_JSON = JSON.parse(
|
||||
readFileSync(join(PKG_ROOT, "package.json"), "utf8")
|
||||
) as { exports: Record<string, unknown>; dependencies: Record<string, string> };
|
||||
|
||||
const REQUIRED_SURFACES = [
|
||||
".",
|
||||
"./karaoke",
|
||||
"./karaoke/lrc-parser",
|
||||
"./karaoke/use-lyrics",
|
||||
"./karaoke/lyrics-display",
|
||||
"./error-codes",
|
||||
];
|
||||
|
||||
describe("subpath exports", () => {
|
||||
it("every public surface has a subpath entry", { timeout: 5000 }, () => {
|
||||
for (const surface of REQUIRED_SURFACES) {
|
||||
expect(PKG_JSON.exports[surface]).toBeDefined();
|
||||
}
|
||||
});
|
||||
|
||||
it("sideEffects=false", { timeout: 5000 }, () => {
|
||||
const raw = JSON.parse(
|
||||
readFileSync(join(PKG_ROOT, "package.json"), "utf8")
|
||||
) as { sideEffects: boolean };
|
||||
expect(raw.sideEffects).toBe(false);
|
||||
});
|
||||
|
||||
it("runtime dependency set matches allowlist", {
|
||||
timeout: 5000,
|
||||
}, () => {
|
||||
const deps = Object.keys(PKG_JSON.dependencies).sort();
|
||||
expect(deps).toEqual(
|
||||
[
|
||||
"@suaveplan/error",
|
||||
"@suaveplan/react-audio",
|
||||
"@suaveplan/types",
|
||||
"tslib",
|
||||
].sort()
|
||||
);
|
||||
});
|
||||
});
|
||||
38
packages/ui/react/react-audio-player/tests/facade.test.tsx
Normal file
38
packages/ui/react/react-audio-player/tests/facade.test.tsx
Normal file
@@ -0,0 +1,38 @@
|
||||
import { describe, expect, it } from "@suaveplan/testing/runner";
|
||||
import * as RAP from "../src/index.js";
|
||||
|
||||
describe("@suaveplan/react-audio-player root barrel", () => {
|
||||
it("exposes the namespaced ReactAudio re-export", { timeout: 5000 }, () => {
|
||||
expect(RAP.ReactAudio).toBeDefined();
|
||||
// The namespace must include the player components.
|
||||
expect(typeof RAP.ReactAudio.AudioProvider).toBe("function");
|
||||
expect(typeof RAP.ReactAudio.AudioPlayer).toBe("function");
|
||||
expect(typeof RAP.ReactAudio.useTransport).toBe("function");
|
||||
expect(typeof RAP.ReactAudio.useAnalyser).toBe("function");
|
||||
expect(typeof RAP.ReactAudio.usePlaylist).toBe("function");
|
||||
});
|
||||
|
||||
it("exposes the flat alias façade", { timeout: 5000 }, () => {
|
||||
expect(typeof RAP.AudioPlayer).toBe("function");
|
||||
expect(typeof RAP.AudioProvider).toBe("function");
|
||||
expect(typeof RAP.BasicPlayer).toBe("function");
|
||||
expect(typeof RAP.PremiumPlayer).toBe("function");
|
||||
expect(typeof RAP.PresetManager).toBe("function");
|
||||
expect(typeof RAP.TransportControls).toBe("function");
|
||||
expect(typeof RAP.useAnalyser).toBe("function");
|
||||
expect(typeof RAP.usePlaylist).toBe("function");
|
||||
});
|
||||
|
||||
it("exposes karaoke surface from root", { timeout: 5000 }, () => {
|
||||
expect(typeof RAP.parseLrc).toBe("function");
|
||||
expect(typeof RAP.activeLyricIndex).toBe("function");
|
||||
expect(typeof RAP.useLyrics).toBe("function");
|
||||
expect(typeof RAP.LyricsDisplay).toBe("function");
|
||||
});
|
||||
|
||||
it("exposes error-code surface from root", { timeout: 5000 }, () => {
|
||||
expect(RAP.REACT_AUDIO_PLAYER_CODES).toBeDefined();
|
||||
expect(typeof RAP.ReactAudioPlayerError).toBe("function");
|
||||
expect(typeof RAP.registerReactAudioPlayerErrorCodes).toBe("function");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user