@cinnabun/testing 0.0.11 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +14 -10
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -14,25 +14,29 @@ Full HTTP server on a random port with `get`, `post`, `put`, `delete` helpers:
14
14
 
15
15
  ```typescript
16
16
  import { describe, it, expect, afterEach } from "bun:test";
17
- import { resolveModuleTree } from "@cinnabun/core";
17
+ import { RestController, GetMapping } from "@cinnabun/core";
18
18
  import { createTestApp, type TestApp } from "@cinnabun/testing";
19
- import { DevDashboardModule } from "@cinnabun/dev-dashboard";
20
19
 
21
- describe("Dashboard", () => {
20
+ describe("API", () => {
22
21
  let app: TestApp;
23
22
 
24
23
  afterEach(async () => {
25
24
  await app.close();
26
25
  });
27
26
 
28
- it("GET /__cinnabun returns HTML", async () => {
29
- const mod = DevDashboardModule.forRoot({ enabled: true, path: "/__cinnabun" });
30
- const { controllers, providers } = await resolveModuleTree(mod);
31
- app = await createTestApp({ controllers, providers });
32
-
33
- const res = await app.get("/__cinnabun");
27
+ it("GET /api returns JSON", async () => {
28
+ @RestController("/api")
29
+ class ApiController {
30
+ @GetMapping("/")
31
+ index() {
32
+ return { message: "Hello" };
33
+ }
34
+ }
35
+
36
+ app = await createTestApp({ controllers: [ApiController] });
37
+ const res = await app.get("/api");
34
38
  expect(res.status).toBe(200);
35
- expect(res.headers.get("Content-Type")).toContain("text/html");
39
+ expect(await res.json()).toEqual({ message: "Hello" });
36
40
  });
37
41
  });
38
42
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cinnabun/testing",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -12,7 +12,7 @@
12
12
  "build": "tsc"
13
13
  },
14
14
  "peerDependencies": {
15
- "@cinnabun/core": ">=0.0.3"
15
+ "@cinnabun/core": "*"
16
16
  },
17
17
  "devDependencies": {
18
18
  "@cinnabun/core": "workspace:*",