mirror of
https://github.com/JonasunderscoreJones/epr.tut.jonasjones.dev.git
synced 2025-10-22 21:29:18 +02:00
added files
This commit is contained in:
parent
a1f3689848
commit
eb1ad6ec71
12 changed files with 3807 additions and 3 deletions
20
test/index.spec.js
Normal file
20
test/index.spec.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
import { env, createExecutionContext, waitOnExecutionContext, SELF } from 'cloudflare:test';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import worker from '../src';
|
||||
|
||||
describe('Hello World worker', () => {
|
||||
it('responds with Hello World! (unit style)', async () => {
|
||||
const request = new Request('http://example.com');
|
||||
// Create an empty context to pass to `worker.fetch()`.
|
||||
const ctx = createExecutionContext();
|
||||
const response = await worker.fetch(request, env, ctx);
|
||||
// Wait for all `Promise`s passed to `ctx.waitUntil()` to settle before running test assertions
|
||||
await waitOnExecutionContext(ctx);
|
||||
expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`);
|
||||
});
|
||||
|
||||
it('responds with Hello World! (integration style)', async () => {
|
||||
const response = await SELF.fetch(request, env, ctx);
|
||||
expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue