mirror of
https://github.com/captbaritone/webamp.git
synced 2026-01-23 10:15:31 +00:00
Add analyzer tests
This commit is contained in:
parent
7a21513a8d
commit
82fbe59a91
1 changed files with 29 additions and 0 deletions
29
packages/skin-database/analyzer.test.ts
Normal file
29
packages/skin-database/analyzer.test.ts
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import fsPromises from "fs";
|
||||
import path from "path";
|
||||
import * as Analyzer from "./analyser";
|
||||
import JSZip from "jszip";
|
||||
|
||||
test("getReadme", async () => {
|
||||
const zip = await getSkinZip("Sonic_Attitude.wsz");
|
||||
const readme = await Analyzer.getReadme(zip);
|
||||
if (readme == null) {
|
||||
throw new Error("Expected to find readme.");
|
||||
}
|
||||
expect(readme.length).toBe(387);
|
||||
expect(readme.split("\n")[0].trim()).toMatchInlineSnapshot(
|
||||
`"SONIC ATTITUDE - By LuigiHann (luigihann@aol.com)"`
|
||||
);
|
||||
});
|
||||
|
||||
test("getSkinType", async () => {
|
||||
const zip = await getSkinZip("Sonic_Attitude.wsz");
|
||||
const skinType = await Analyzer.getSkinType(zip);
|
||||
expect(skinType).toBe("CLASSIC");
|
||||
});
|
||||
|
||||
function getSkinZip(filename: string): Promise<JSZip> {
|
||||
const buffer = fsPromises.readFileSync(
|
||||
path.join(__dirname, "../webamp/demo/skins/", filename)
|
||||
);
|
||||
return JSZip.loadAsync(buffer);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue