Skip to content

Commit

Permalink
workers tests: check for Italian responses
Browse files Browse the repository at this point in the history
  • Loading branch information
wydengyre committed Jan 29, 2024
1 parent 4fb9a2b commit a903a83
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion cf/worker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { createServerAdapter } from "@whatwg-node/server";
import { Router, RouterType, error, json } from "itty-router";
import { UnstableDevWorker, unstable_dev } from "wrangler";
import genresJson from "../rai/test/generi.json" with { type: "json" };
import { assertItalian } from "../server/test/headers.js";
import feedJson from "./test/lastoriaingiallo.json" with { type: "json" };
import expectedJson from "./test/lastoriaingiallo.parsed.json" with {
type: "json",
Expand Down Expand Up @@ -81,7 +82,7 @@ async function index() {
assert(resp.ok);
assert.strictEqual(resp.status, 200);
assert.strictEqual(resp.statusText, "OK");
assert.strictEqual(resp.headers.get("Content-Language"), "it");
assertItalian(resp);

const _text = await resp.text();
// TODO: validate html
Expand All @@ -106,6 +107,7 @@ async function rssFeedSuccess() {
const resp = await worker.fetch("/programmi/lastoriaingiallo.xml");
assert(resp.ok);
assert.strictEqual(resp.status, 200);
assertItalian(resp);

const feed = await resp.text();
const parsedFeed = parseFeed(feed);
Expand Down
7 changes: 5 additions & 2 deletions server/test/headers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { strict as assert } from "node:assert";

export { assertItalian };
function assertItalian(response: Response) {
assert.strictEqual(response.headers.get("Content-Language"), "it");

function assertItalian({
headers,
}: { headers: { readonly get: (name: string) => string | null } }) {
assert.strictEqual(headers.get("Content-Language"), "it");
}

0 comments on commit a903a83

Please sign in to comment.