-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathmisc.test.ts
More file actions
37 lines (30 loc) · 918 Bytes
/
misc.test.ts
File metadata and controls
37 lines (30 loc) · 918 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { env, fetchMock, createExecutionContext } from 'cloudflare:test';
import { test, beforeAll, expect } from 'vitest';
import { populateR2WithDevBucket } from './util';
import worker from '../src/worker';
import type { Env } from '../src/env';
const mockedEnv: Env = {
...env,
ENVIRONMENT: 'e2e-tests',
CACHING: false,
LOG_ERRORS: true,
};
beforeAll(async () => {
fetchMock.activate();
fetchMock.disableNetConnect();
await populateR2WithDevBucket();
});
// Ensure methods we don't support are handled properly
for (const method of ['POST', 'PATCH', 'PUT', 'DELETE', 'PROPFIND']) {
test(`${method} \`/\` returns a 405`, async () => {
const ctx = createExecutionContext();
const res = await worker.fetch(
new Request('https://localhost/', { method }),
mockedEnv,
ctx
);
// Consume body promise
await res.text();
expect(res.status).toBe(405);
});
}