Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions uzumibi-on-cloudflare-spike/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,29 @@ import { env, createExecutionContext, waitOnExecutionContext, SELF } from 'cloud
import { describe, it, expect } from 'vitest';
import worker from '../src';

describe('Hello World worker', () => {
it('responds with Hello World! (unit style)', async () => {
describe('Uzumibi worker', () => {
it('responds with Uzumibi (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!"`);
expect(await response.text()).toMatchInlineSnapshot(`
""Uzumibi" is a Japanese term that refers
to live embers buried under a layer of ash
to keep the fire from going out.
"
`);
});

it('responds with Hello World! (integration style)', async () => {
it('responds with Uzumibi (integration style)', async () => {
const response = await SELF.fetch('http://example.com');
expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`);
expect(await response.text()).toMatchInlineSnapshot(`
""Uzumibi" is a Japanese term that refers
to live embers buried under a layer of ash
to keep the fire from going out.
"
`);
});
});