A decentralized music tracking and discovery platform built on AT Protocol 馃幍
at fix/spotify 25 lines 1.1 kB view raw
1// test/index.spec.ts 2import { env, createExecutionContext, waitOnExecutionContext, SELF } from 'cloudflare:test'; 3import { describe, it, expect } from 'vitest'; 4import worker from '../src/index'; 5 6// For now, you'll need to do something like this to get a correctly-typed 7// `Request` to pass to `worker.fetch()`. 8const IncomingRequest = Request<unknown, IncomingRequestCfProperties>; 9 10describe('Hello World worker', () => { 11 it('responds with Hello World! (unit style)', async () => { 12 const request = new IncomingRequest('http://example.com'); 13 // Create an empty context to pass to `worker.fetch()`. 14 const ctx = createExecutionContext(); 15 const response = await worker.fetch(request, env, ctx); 16 // Wait for all `Promise`s passed to `ctx.waitUntil()` to settle before running test assertions 17 await waitOnExecutionContext(ctx); 18 expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`); 19 }); 20 21 it('responds with Hello World! (integration style)', async () => { 22 const response = await SELF.fetch('https://example.com'); 23 expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`); 24 }); 25});