Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
add xspace-agent/agent-voice-chat/tests/unit/middleware/validate.test.js
oversteppingf871c6c14054
diff --git a/xspace-agent/agent-voice-chat/tests/unit/middleware/validate.test.js b/xspace-agent/agent-voice-chat/tests/unit/middleware/validate.test.jsnew file mode 100644index 000000000..65217ec6a--- /dev/null+++ b/xspace-agent/agent-voice-chat/tests/unit/middleware/validate.test.js@@ -0,0 +1,64 @@+// SPDX-License-Identifier: Apache-2.0+// Copyright 2026 nirholas (https://github.com/nirholas/xspace-agent)++import { z } from "zod"+import { validate } from "../../../src/server/middleware/validate"++describe("validate middleware", () => {+ const schema = z.object({+ name: z.string().min(1),+ age: z.number().int().positive()+ })++ function createMocks(body) {+ return {+ req: { body },+ res: {+ status: vi.fn().mockReturnThis(),+ json: vi.fn()+ },+ next: vi.fn()+ }+ }++ it("should call next() with valid body", () => {+ const { req, res, next } = createMocks({ name: "Alice", age: 30 })+ validate(schema)(req, res, next)+ expect(next).toHaveBeenCalledWith()+ expect(req.body).toEqual({ name: "Alice", age: 30 })+ })++ it("should return 400 on invalid body", () => {+ const { req, res, next } = createMocks({ name: "", age: -5 })+ validate(schema)(req, res, next)+ expect(res.status).toHaveBeenCalledWith(400)+ expect(res.json).toHaveBeenCalledWith(+ expect.objectContaining({+ error: expect.objectContaining({+ code: "VALIDATION_ERROR",+ details: expect.any(Array)+ })+ })+ )+ expect(next).not.toHaveBeenCalled()+ })++ it("should return error details for each invalid field", () => {+ const { req, res, next } = createMocks({})+ validate(schema)(req, res, next)+ expect(res.status).toHaveBeenCalledWith(400)+ const errorBody = res.json.mock.calls[0][0]+ expect(errorBody.error.details.length).toBeGreaterThan(0)+ })++ it("should pass non-Zod errors to next()", () => {+ const badSchema = {+ parse() { throw new Error("unexpected") }+ }+ const { req, res, next } = createMocks({})+ validate(badSchema)(req, res, next)+ expect(next).toHaveBeenCalledWith(expect.any(Error))+ })+})++