From 32c06a6fd52cb52aa0a00af0c7698001fbba6ec3 Mon Sep 17 00:00:00 2001 From: Ashish Padhy <100484401+Shurtu-gal@users.noreply.github.com> Date: Fri, 22 Dec 2023 15:03:42 +0530 Subject: [PATCH] chore: add some more tests * assert returned content type --- netlify/edge-functions/serve-definitions.ts | 1 + .../tests/serve-definitions.test.ts | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/netlify/edge-functions/serve-definitions.ts b/netlify/edge-functions/serve-definitions.ts index f1afa846491c..0bde8bec5ed0 100644 --- a/netlify/edge-functions/serve-definitions.ts +++ b/netlify/edge-functions/serve-definitions.ts @@ -1,3 +1,4 @@ +// Changes to URL from 'netlify:edge' because we don't have package aliasing setup in our workflow. import type { Context } from "https://edge-bootstrap.netlify.app/v1/index.ts"; const GITHUB_TOKEN = Deno.env.get("GITHUB_TOKEN_NR"); diff --git a/netlify/edge-functions/tests/serve-definitions.test.ts b/netlify/edge-functions/tests/serve-definitions.test.ts index 60365842056f..04333c2b7025 100644 --- a/netlify/edge-functions/tests/serve-definitions.test.ts +++ b/netlify/edge-functions/tests/serve-definitions.test.ts @@ -11,6 +11,16 @@ const validRequests = [ responseURL: "https://raw.githubusercontent.com/asyncapi/spec-json-schemas/master/definitions/2.4.0/info.json", }, + { + requestURL: "https://asyncapi.com/definitions/2.4.0.json", + responseURL: + "https://raw.githubusercontent.com/asyncapi/spec-json-schemas/master/schemas/2.4.0.json", + }, + { + requestURL: "https://asyncapi.com/schema-store/2.5.0/operation.json", + responseURL: + "https://raw.githubusercontent.com/asyncapi/spec-json-schemas/master/definitions/2.5.0/operation.json", + }, { requestURL: "https://asyncapi.com/schema-store/2.5.0-without-$id.json", responseURL: @@ -27,7 +37,10 @@ const invalidRequests = [ }, { requestURL: "https://asyncapi.com/foobar", - } + }, + { + requestURL: "https://asyncapi.com/", + }, ]; const context = { @@ -75,6 +88,7 @@ Deno.test("serve-definitions test for validRequests", async () => { const body = await response.json(); assertEquals(response.status, 200); + assertEquals(response.headers.get("Content-Type"), "application/schema+json"); assertEquals(body.url, entry.responseURL); console.log("\n");