Skip to content

Commit

Permalink
chore: add some more tests
Browse files Browse the repository at this point in the history
* assert returned content type
  • Loading branch information
Shurtu-gal committed Dec 22, 2023
1 parent 5ae2851 commit 32c06a6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions netlify/edge-functions/serve-definitions.ts
Original file line number Diff line number Diff line change
@@ -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");
Expand Down
16 changes: 15 additions & 1 deletion netlify/edge-functions/tests/serve-definitions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -27,7 +37,10 @@ const invalidRequests = [
},
{
requestURL: "https://asyncapi.com/foobar",
}
},
{
requestURL: "https://asyncapi.com/",
},
];

const context = {
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 32c06a6

Please sign in to comment.