summaryrefslogtreecommitdiff
path: root/tst/fourohfour.test.ts
diff options
context:
space:
mode:
authorElizabeth Hunt <me@liz.coffee>2025-12-14 22:39:18 -0800
committerElizabeth Hunt <me@liz.coffee>2025-12-14 22:39:18 -0800
commit666674327f009e9b1013218fc384f193b64c6997 (patch)
treeacebae7b425b469584eb0a5bec396899c2739501 /tst/fourohfour.test.ts
parent594ce452693a71b501d3aff3f35ef3732c06c341 (diff)
downloadpengueno-666674327f009e9b1013218fc384f193b64c6997.tar.gz
pengueno-666674327f009e9b1013218fc384f193b64c6997.zip
Adds unit tests
Diffstat (limited to 'tst/fourohfour.test.ts')
-rw-r--r--tst/fourohfour.test.ts38
1 files changed, 38 insertions, 0 deletions
diff --git a/tst/fourohfour.test.ts b/tst/fourohfour.test.ts
new file mode 100644
index 0000000..c8fdd6f
--- /dev/null
+++ b/tst/fourohfour.test.ts
@@ -0,0 +1,38 @@
+import { FourOhFourActivityImpl, PenguenoRequest, type BaseRequest, type ServerTrace } from '../lib/index';
+import { CollectingTrace, TestTraceable } from './test_utils';
+
+const makeBaseRequest = (overrides: Partial<BaseRequest> = {}): BaseRequest => ({
+ url: 'https://example.com/missing',
+ method: 'GET',
+ header: () => ({}),
+ formData: async () => new FormData(),
+ json: async () => ({}),
+ text: async () => '',
+ param: () => undefined,
+ query: () => ({}),
+ queries: () => ({}),
+ ...overrides,
+});
+
+describe('server/activity/fourohfour (FourOhFourActivityImpl)', () => {
+ beforeEach(() => {
+ jest.spyOn(globalThis.crypto, 'randomUUID').mockReturnValue('00000000-0000-0000-0000-000000000000');
+ jest.spyOn(Math, 'random').mockReturnValue(0);
+ });
+
+ afterEach(() => {
+ jest.restoreAllMocks();
+ });
+
+ test('returns JsonResponse with 404', async () => {
+ const trace = new CollectingTrace<ServerTrace>();
+ const req = PenguenoRequest.from(TestTraceable.of(makeBaseRequest(), trace));
+
+ const activity = new FourOhFourActivityImpl();
+ const resp = await activity.fourOhFour(req);
+
+ expect(resp.status).toBe(404);
+ expect(resp.headers['Content-Type']).toBe('application/json; charset=utf-8');
+ expect(resp.body()).toContain('"error"');
+ });
+});