Initial Commit
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import { describe, expect, it } from "@suaveplan/testing/runner";
|
||||
import type { AudioClipInput } from "../src/index.js";
|
||||
import { AudioSpritePacker, NullAudioAdapter } from "../src/index.js";
|
||||
|
||||
describe("integration", () => {
|
||||
it("full pack/unpack round-trip", { timeout: 5000 }, async () => {
|
||||
const packer = new AudioSpritePacker({
|
||||
adapter: new NullAudioAdapter(),
|
||||
});
|
||||
const clips: AudioClipInput[] = [
|
||||
{ name: "intro", data: new Uint8Array([1, 2]) },
|
||||
{ name: "loop", data: new Uint8Array([3, 4, 5]) },
|
||||
{ name: "outro", data: new Uint8Array([6]) },
|
||||
];
|
||||
const sprite = await packer.pack(clips);
|
||||
expect(sprite.manifest.entries).toHaveLength(3);
|
||||
expect(sprite.manifest.version).toBe(1);
|
||||
expect(sprite.manifest.contentHash).toHaveLength(64);
|
||||
|
||||
for (const entry of sprite.manifest.entries) {
|
||||
const slice = packer.unpack(sprite, entry.name);
|
||||
expect(slice.length).toBe(entry.byteLength);
|
||||
}
|
||||
});
|
||||
|
||||
it("pack with normalise and stripSilence", { timeout: 5000 }, async () => {
|
||||
const packer = new AudioSpritePacker({
|
||||
adapter: new NullAudioAdapter(),
|
||||
});
|
||||
const clips: AudioClipInput[] = [
|
||||
{ name: "a", data: new Uint8Array([1]) },
|
||||
{ name: "b", data: new Uint8Array([2]) },
|
||||
];
|
||||
const sprite = await packer.pack(clips, {
|
||||
normalise: true,
|
||||
stripSilence: true,
|
||||
silencePaddingMs: 50,
|
||||
});
|
||||
expect(sprite.manifest.entries).toHaveLength(2);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user