style: format code with prettier
Local Build and Deploy / deploy (push) Successful in 49s

This commit is contained in:
openhands committed 2026-07-12 21:07:34 +02:00
1 parent e85e4d74ea
commit 2e4ed76121
378 files changed
+22404 -20686

No files matched your search

+30 -31
View File
@@ -1,48 +1,47 @@
// @vitest-environment node
import { describe, expect, it, vi } from 'vitest'
import { describe, expect, it, vi } from "vitest";
vi.mock('@/lib/services/import/core/download', () => ({
vi.mock("@/lib/services/import/core/download", () => ({
downloadFile: vi.fn(async () => ({ ok: true, size: 100 })),
}))
vi.mock('@/lib/services/pet-source', () => ({
CANONICAL_PETS: ['dog', 'cat'],
}));
vi.mock("@/lib/services/pet-source", () => ({
CANONICAL_PETS: ["dog", "cat"],
resolvePetSwfUrl: vi.fn(async (lib: string) => `https://x/${lib}.swf`),
}))
const convertSwfToNitro = vi.fn(() => ({ bundle: Buffer.from('nitro'), warnings: [] }))
vi.mock('@/lib/services/swf-to-nitro', () => ({
convertSwfToNitro: (...a: unknown[]) =>
convertSwfToNitro(...(a as Parameters<typeof convertSwfToNitro>)),
}))
vi.mock('node:fs', async (orig) => {
const real = (await orig()) as typeof import('node:fs')
}));
const convertSwfToNitro = vi.fn(() => ({ bundle: Buffer.from("nitro"), warnings: [] }));
vi.mock("@/lib/services/swf-to-nitro", () => ({
convertSwfToNitro: (...a: unknown[]) => convertSwfToNitro(...(a as Parameters<typeof convertSwfToNitro>)),
}));
vi.mock("node:fs", async (orig) => {
const real = (await orig()) as typeof import("node:fs");
return {
...real,
existsSync: vi.fn(() => false),
promises: {
...real.promises,
readFile: vi.fn(async () => Buffer.from('CWS')),
readFile: vi.fn(async () => Buffer.from("CWS")),
writeFile: vi.fn(async () => {}),
mkdir: vi.fn(async () => {}),
unlink: vi.fn(async () => {}),
},
}
})
};
});
import { importSinglePet } from './pet-import'
import { importSinglePet } from "./pet-import";
describe('pet-import.importSinglePet', () => {
it('downloads, converts, writes .nitro', async () => {
const r = await importSinglePet({ lib: 'dog' })
expect(r.ok).toBe(true)
expect(convertSwfToNitro).toHaveBeenCalled()
})
describe("pet-import.importSinglePet", () => {
it("downloads, converts, writes .nitro", async () => {
const r = await importSinglePet({ lib: "dog" });
expect(r.ok).toBe(true);
expect(convertSwfToNitro).toHaveBeenCalled();
});
it('fails cleanly when conversion throws', async () => {
it("fails cleanly when conversion throws", async () => {
convertSwfToNitro.mockImplementationOnce(() => {
throw new Error('bad swf')
})
const r = await importSinglePet({ lib: 'cat' })
expect(r.ok).toBe(false)
expect(r.error).toContain('conversion')
})
})
throw new Error("bad swf");
});
const r = await importSinglePet({ lib: "cat" });
expect(r.ok).toBe(false);
expect(r.error).toContain("conversion");
});
});