Preserve furniture revisions when downloading source assets
This commit is contained in:
1 parent
7880d5d5df
commit
8a919f85b2
5 files changed
+32
-4
No files matched your search
@@ -4,6 +4,8 @@ import { MySqlDialect } from "drizzle-orm/mysql-core";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
official: vi.fn(),
|
||||
download: vi.fn(),
|
||||
execute: vi.fn(),
|
||||
select: vi.fn(),
|
||||
stat: vi.fn(),
|
||||
@@ -43,14 +45,14 @@ vi.mock("@/lib/services/furni-data", () => ({
|
||||
appendFurniEntry: mocks.append,
|
||||
}));
|
||||
vi.mock("@/lib/services/habbo-furnidata-cache", () => ({
|
||||
lookupOfficialHabboFurni: async () => null,
|
||||
lookupOfficialHabboFurni: mocks.official,
|
||||
}));
|
||||
vi.mock("@/lib/services/habbo-gamedata-hotel", () => ({
|
||||
getHabboGamedataHotel: async () => "it",
|
||||
}));
|
||||
vi.mock("@/lib/services/import/core/download", () => ({
|
||||
downloadFile: vi.fn(),
|
||||
tryDownloadCandidates: async () => false,
|
||||
tryDownloadCandidates: mocks.download,
|
||||
}));
|
||||
vi.mock("@/lib/services/swf-to-nitro", () => ({
|
||||
parseNitroBundle: () => ({ json: {} }),
|
||||
@@ -76,6 +78,8 @@ function queries() {
|
||||
describe("completion of existing furniture", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
mocks.official.mockResolvedValue(null);
|
||||
mocks.download.mockResolvedValue(false);
|
||||
const rows = [
|
||||
[{ id: 2000037257, spriteId: 9001, type: "s" }],
|
||||
[{ itemName: input.classname }],
|
||||
@@ -140,13 +144,22 @@ it("imports recycler_kintsugiB with an allocated ID throughout SQL and furnidata
|
||||
return [[{ id: 123, page_id: "15" }], []];
|
||||
return [[], []];
|
||||
});
|
||||
mocks.official.mockResolvedValue({ revision: 73706, xdim: 1, ydim: 1 });
|
||||
const result = await importSingleFurni({
|
||||
...input,
|
||||
revision: 0,
|
||||
id: 16940,
|
||||
classname: "recycler_kintsugiB",
|
||||
});
|
||||
expect(result.ok).toBe(true);
|
||||
expect(result.itemId).toBe(2000037258);
|
||||
expect(mocks.download).toHaveBeenCalledWith(
|
||||
expect.arrayContaining([
|
||||
"https://images.habbo.com/dcr/hof_furni/73706/recycler_kintsugiB.swf",
|
||||
]),
|
||||
expect.any(String),
|
||||
"swf",
|
||||
);
|
||||
expect(mocks.build).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
id: 2000037258,
|
||||
|
||||
Reference in new issue
Block a user