Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 21, 04:45 UTC
| 1 | import { env, createExecutionContext, waitOnExecutionContext, SELF } from 'cloudflare:test'; |
| 2 | import { describe, it, expect } from 'vitest'; |
| 3 | import worker from '../src/index'; |
| 4 | |
| 5 | // For now, you'll need to do something like this to get a correctly-typed |
| 6 | // `Request` to pass to `worker.fetch()`. |
| 7 | const IncomingRequest = Request<unknown, IncomingRequestCfProperties>; |
| 8 | |
| 9 | describe('Hello World worker', () => { |
| 10 | it('responds with Hello World! (unit style)', async () => { |
| 11 | const request = new IncomingRequest('http://example.com'); |
| 12 | // Create an empty context to pass to `worker.fetch()`. |
| 13 | const ctx = createExecutionContext(); |
| 14 | const response = await worker.fetch(request, env, ctx); |
| 15 | // Wait for all `Promise`s passed to `ctx.waitUntil()` to settle before running test assertions |
| 16 | await waitOnExecutionContext(ctx); |
| 17 | expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`); |
| 18 | }); |
| 19 | |
| 20 | it('responds with Hello World! (integration style)', async () => { |
| 21 | const response = await SELF.fetch('https://example.com'); |
| 22 | expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`); |
| 23 | }); |
| 24 | }); |