microsoft/typespec
Publicmirrored from https://github.com/microsoft/typespecAvailable
packages/openapi/test/test-host.ts
17lines · modecode
| 1 | import { createTestHost, createTestWrapper } from "@cadl-lang/compiler/testing"; |
| 2 | import { RestTestLibrary } from "@cadl-lang/rest/testing"; |
| 3 | import { OpenAPITestLibrary } from "../src/testing/index.js"; |
| 4 | |
| 5 | export async function createOpenAPITestHost() { |
| 6 | return createTestHost({ |
| 7 | libraries: [RestTestLibrary, OpenAPITestLibrary], |
| 8 | }); |
| 9 | } |
| 10 | export async function createOpenAPITestRunner() { |
| 11 | const host = await createOpenAPITestHost(); |
| 12 | return createTestWrapper( |
| 13 | host, |
| 14 | (code) => |
| 15 | `import "@cadl-lang/rest"; import "@cadl-lang/openapi";using Cadl.Rest;using Cadl.Http;using OpenAPI;${code}` |
| 16 | ); |
| 17 | } |
| 18 | |