Files
CurrenciCombo/orchestrator/tests/integration/plans.test.ts

52 lines
1.3 KiB
TypeScript
Raw Normal View History

import { describe, it, expect, beforeAll, afterAll } from "@jest/globals";
import request from "supertest";
import express from "express";
import { createPlan, getPlan } from "../../src/api/plans";
// Mock Express app
const app = express();
app.use(express.json());
app.post("/api/plans", createPlan);
app.get("/api/plans/:planId", getPlan);
describe("Plan Management Integration Tests", () => {
it("should create a plan", async () => {
const plan = {
creator: "test-user",
steps: [
{ type: "borrow", asset: "CBDC_USD", amount: 100000 },
],
};
const response = await request(app)
.post("/api/plans")
.send(plan)
.expect(201);
expect(response.body).toHaveProperty("plan_id");
expect(response.body).toHaveProperty("plan_hash");
});
it("should get a plan by ID", async () => {
// First create a plan
const plan = {
creator: "test-user",
steps: [{ type: "borrow", asset: "CBDC_USD", amount: 100000 }],
};
const createResponse = await request(app)
.post("/api/plans")
.send(plan);
const planId = createResponse.body.plan_id;
// Then get it
const getResponse = await request(app)
.get(`/api/plans/${planId}`)
.expect(200);
expect(getResponse.body.plan_id).toBe(planId);
});
});