mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-23 01:57:29 +00:00
Fix and cleanup tests
This commit is contained in:
parent
303a83a8c2
commit
e342c45f20
5 changed files with 119 additions and 94 deletions
97
packages/webamp/js/__snapshots__/aniParser.test.ts.snap
Normal file
97
packages/webamp/js/__snapshots__/aniParser.test.ts.snap
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Green Dimension v2.wsz eqslid.cur 1`] = `
|
||||
Object {
|
||||
"images": "00201032320000001681600220004000032000640001032000000160000000000000000,00201032320000001681600220004000032000640001032000000160000000000000000...",
|
||||
"metadata": Object {
|
||||
"bfAttributes": 1,
|
||||
"cbSize": 36,
|
||||
"iBitCount": 0,
|
||||
"iDispRate": 10,
|
||||
"iHeight": 0,
|
||||
"iWidth": 0,
|
||||
"nFrames": 2,
|
||||
"nPlanes": 0,
|
||||
"nSteps": 2,
|
||||
},
|
||||
"rate": Array [
|
||||
8,
|
||||
8,
|
||||
],
|
||||
"seq": null,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Super_Mario_Amp_2.wsz close.cur 1`] = `
|
||||
Object {
|
||||
"images": "0020103232000000168800220004000032000640001080000012840000000000000000,0020103232000000168800220004000032000640001080000012840000000000000000,0020103232000000168800220004000032000640001080000012840000000000000000,0020103232000000168800220004000032000640001080000012840000000000000000,0020103232000000168800220004000032000640001080000012840000000000000000,0020103232000000168800220004000032000640001080000012840000000000000000,0020103232000000168800220004000032000640001080000012840000000000000000,0020103232000000168800220004000032000640001080000012840000000000000000,0020103232000000168800220004000032000640001080000012840000000000000000,0020103232000000168800220004000032000640001080000012840000000000000000...",
|
||||
"metadata": Object {
|
||||
"bfAttributes": 3,
|
||||
"cbSize": 36,
|
||||
"iBitCount": 4,
|
||||
"iDispRate": 10,
|
||||
"iHeight": 0,
|
||||
"iWidth": 0,
|
||||
"nFrames": 10,
|
||||
"nPlanes": 1,
|
||||
"nSteps": 17,
|
||||
},
|
||||
"rate": Array [
|
||||
10,
|
||||
10,
|
||||
10,
|
||||
10,
|
||||
7,
|
||||
6,
|
||||
5,
|
||||
4,
|
||||
3,
|
||||
2,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
60,
|
||||
],
|
||||
"seq": Array [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
4,
|
||||
5,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
8,
|
||||
9,
|
||||
8,
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Super_Mario_Amp_2.wsz eqslid.cur 1`] = `
|
||||
Object {
|
||||
"images": "0020103232000000168120022000400003200064000102400000128120000000000000000,0020103232000000168120022000400003200064000102400000128120000000000000000,0020103232000000168120022000400003200064000102400000128120000000000000000,0020103232000000168120022000400003200064000102400000128120000000000000000,0020103232000000168120022000400003200064000102400000128120000000000000000,0020103232000000168120022000400003200064000102400000128120000000000000000,0020103232000000168120022000400003200064000102400000128120000000000000000,0020103232000000168120022000400003200064000102400000128120000000000000000...",
|
||||
"metadata": Object {
|
||||
"bfAttributes": 1,
|
||||
"cbSize": 36,
|
||||
"iBitCount": 4,
|
||||
"iDispRate": 10,
|
||||
"iHeight": 0,
|
||||
"iWidth": 0,
|
||||
"nFrames": 8,
|
||||
"nPlanes": 1,
|
||||
"nSteps": 8,
|
||||
},
|
||||
"rate": null,
|
||||
"seq": null,
|
||||
}
|
||||
`;
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,106 +1,34 @@
|
|||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { parseAni, ParsedAni } from "./aniParser";
|
||||
import { parseAni } from "./aniParser";
|
||||
|
||||
function parsePath(filePath: string): ParsedAni {
|
||||
// Parse a `.ani` in our fixture directory and trim down the image data for use
|
||||
// in snapshot tests.
|
||||
function parsePath(filePath: string) {
|
||||
const buffer = fs.readFileSync(
|
||||
path.join(__dirname, "./__tests__/fixtures/ani/", filePath)
|
||||
);
|
||||
|
||||
return parseAni(buffer);
|
||||
const ani = parseAni(buffer);
|
||||
const imgString = ani.images.map((image) => image.slice(0, 60).join(""));
|
||||
// @ts-ignore
|
||||
ani.images = `${imgString}...`;
|
||||
return ani;
|
||||
}
|
||||
|
||||
test("Super_Mario_Amp_2.wsz eqslid.cur", async () => {
|
||||
const ani = parsePath("Super_Mario_Amp_2/eqslid.cur");
|
||||
// @ts-ignore
|
||||
ani.images = ani.images.map((image) => image.slice(0, 60).join(""));
|
||||
expect(ani).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"images": Array [
|
||||
"0020103232000000168120022000400003200064000102400000128120000000000000000",
|
||||
"0020103232000000168120022000400003200064000102400000128120000000000000000",
|
||||
"0020103232000000168120022000400003200064000102400000128120000000000000000",
|
||||
"0020103232000000168120022000400003200064000102400000128120000000000000000",
|
||||
"0020103232000000168120022000400003200064000102400000128120000000000000000",
|
||||
"0020103232000000168120022000400003200064000102400000128120000000000000000",
|
||||
"0020103232000000168120022000400003200064000102400000128120000000000000000",
|
||||
"0020103232000000168120022000400003200064000102400000128120000000000000000",
|
||||
],
|
||||
"metadata": Object {
|
||||
"bfAttributes": 1,
|
||||
"cbSize": 36,
|
||||
"iBitCount": 4,
|
||||
"iDispRate": 10,
|
||||
"iHeight": 0,
|
||||
"iWidth": 0,
|
||||
"nFrames": 8,
|
||||
"nPlanes": 1,
|
||||
"nSteps": 8,
|
||||
},
|
||||
"rate": null,
|
||||
"seq": null,
|
||||
}
|
||||
`);
|
||||
// https://skins.webamp.org/skin/6e30f9e9b8f5719469809785ae5e4a1f/Super_Mario_Amp_2.wsz/
|
||||
describe("Super_Mario_Amp_2.wsz", () => {
|
||||
test("eqslid.cur", async () => {
|
||||
expect(parsePath("Super_Mario_Amp_2/eqslid.cur")).toMatchSnapshot();
|
||||
});
|
||||
test("close.cur", async () => {
|
||||
expect(parsePath("Super_Mario_Amp_2/close.cur")).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
test("Green Dimension v2.wsz eqslid.cur", async () => {
|
||||
const ani = parsePath("Green_Dimension_v2/Eqslid.cur");
|
||||
// @ts-ignore
|
||||
ani.images = ani.images.map((image) => image.slice(0, 60).join(""));
|
||||
expect(ani).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"images": Array [
|
||||
"00201032320000001681600220004000032000640001032000000160000000000000000",
|
||||
"00201032320000001681600220004000032000640001032000000160000000000000000",
|
||||
],
|
||||
"metadata": Object {
|
||||
"bfAttributes": 1,
|
||||
"cbSize": 36,
|
||||
"iBitCount": 0,
|
||||
"iDispRate": 10,
|
||||
"iHeight": 0,
|
||||
"iWidth": 0,
|
||||
"nFrames": 2,
|
||||
"nPlanes": 0,
|
||||
"nSteps": 2,
|
||||
},
|
||||
"rate": Array [
|
||||
8,
|
||||
8,
|
||||
],
|
||||
"seq": null,
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test("rainbow", async () => {
|
||||
const ani = parsePath("Rainbow classic.ani");
|
||||
// @ts-ignore
|
||||
ani.images = ani.images.map((image) => image.slice(0, 60).join(""));
|
||||
expect(ani).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"images": Array [
|
||||
"0020103232000000168160022000400003200064000103200000128160000000000000000",
|
||||
"0020103232000000168160022000400003200064000103200000128160000000000000000",
|
||||
"0020103232000000168160022000400003200064000103200000128160000000000000000",
|
||||
"0020103232000000168160022000400003200064000103200000128160000000000000000",
|
||||
"0020103232000000168160022000400003200064000103200000128160000000000000000",
|
||||
"0020103232000000168160022000400003200064000103200000128160000000000000000",
|
||||
"0020103232000000168160022000400003200064000103200000128160000000000000000",
|
||||
],
|
||||
"metadata": Object {
|
||||
"bfAttributes": 1,
|
||||
"cbSize": 36,
|
||||
"iBitCount": 0,
|
||||
"iDispRate": 7,
|
||||
"iHeight": 0,
|
||||
"iWidth": 0,
|
||||
"nFrames": 7,
|
||||
"nPlanes": 0,
|
||||
"nSteps": 7,
|
||||
},
|
||||
"rate": null,
|
||||
"seq": null,
|
||||
}
|
||||
`);
|
||||
// https://skins.webamp.org/skin/4308a2fc648033bf5fe7c4d56a5c8823/Green-Dimension-V2.wsz/
|
||||
describe("Green Dimension v2.wsz", () => {
|
||||
test("eqslid.cur", async () => {
|
||||
expect(parsePath("Green Dimension v2/eqslid.cur")).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue