cloudflare/cloudflare-typescript
Publicmirrored fromhttps://github.com/cloudflare/cloudflare-typescriptAvailable
tests/api-resources/ai-gateway/evaluations.test.ts
99lines · modecode
| 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | |
| 3 | import Cloudflare from 'cloudflare'; |
| 4 | import { Response } from 'node-fetch'; |
| 5 | |
| 6 | const client = new Cloudflare({ |
| 7 | apiKey: '144c9defac04969c7bfad8efaa8ea194', |
| 8 | apiEmail: 'user@example.com', |
| 9 | baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', |
| 10 | }); |
| 11 | |
| 12 | describe('resource evaluations', () => { |
| 13 | test('create: only required params', async () => { |
| 14 | const responsePromise = client.aiGateway.evaluations.create('my-gateway', { |
| 15 | account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0', |
| 16 | dataset_ids: ['string'], |
| 17 | evaluation_type_ids: ['string'], |
| 18 | name: 'name', |
| 19 | }); |
| 20 | const rawResponse = await responsePromise.asResponse(); |
| 21 | expect(rawResponse).toBeInstanceOf(Response); |
| 22 | const response = await responsePromise; |
| 23 | expect(response).not.toBeInstanceOf(Response); |
| 24 | const dataAndResponse = await responsePromise.withResponse(); |
| 25 | expect(dataAndResponse.data).toBe(response); |
| 26 | expect(dataAndResponse.response).toBe(rawResponse); |
| 27 | }); |
| 28 | |
| 29 | test('create: required and optional params', async () => { |
| 30 | const response = await client.aiGateway.evaluations.create('my-gateway', { |
| 31 | account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0', |
| 32 | dataset_ids: ['string'], |
| 33 | evaluation_type_ids: ['string'], |
| 34 | name: 'name', |
| 35 | }); |
| 36 | }); |
| 37 | |
| 38 | test('list: only required params', async () => { |
| 39 | const responsePromise = client.aiGateway.evaluations.list('my-gateway', { |
| 40 | account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0', |
| 41 | }); |
| 42 | const rawResponse = await responsePromise.asResponse(); |
| 43 | expect(rawResponse).toBeInstanceOf(Response); |
| 44 | const response = await responsePromise; |
| 45 | expect(response).not.toBeInstanceOf(Response); |
| 46 | const dataAndResponse = await responsePromise.withResponse(); |
| 47 | expect(dataAndResponse.data).toBe(response); |
| 48 | expect(dataAndResponse.response).toBe(rawResponse); |
| 49 | }); |
| 50 | |
| 51 | test('list: required and optional params', async () => { |
| 52 | const response = await client.aiGateway.evaluations.list('my-gateway', { |
| 53 | account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0', |
| 54 | name: 'name', |
| 55 | page: 1, |
| 56 | per_page: 1, |
| 57 | processed: true, |
| 58 | search: 'search', |
| 59 | }); |
| 60 | }); |
| 61 | |
| 62 | test('delete: only required params', async () => { |
| 63 | const responsePromise = client.aiGateway.evaluations.delete('my-gateway', 'id', { |
| 64 | account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0', |
| 65 | }); |
| 66 | const rawResponse = await responsePromise.asResponse(); |
| 67 | expect(rawResponse).toBeInstanceOf(Response); |
| 68 | const response = await responsePromise; |
| 69 | expect(response).not.toBeInstanceOf(Response); |
| 70 | const dataAndResponse = await responsePromise.withResponse(); |
| 71 | expect(dataAndResponse.data).toBe(response); |
| 72 | expect(dataAndResponse.response).toBe(rawResponse); |
| 73 | }); |
| 74 | |
| 75 | test('delete: required and optional params', async () => { |
| 76 | const response = await client.aiGateway.evaluations.delete('my-gateway', 'id', { |
| 77 | account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0', |
| 78 | }); |
| 79 | }); |
| 80 | |
| 81 | test('get: only required params', async () => { |
| 82 | const responsePromise = client.aiGateway.evaluations.get('my-gateway', 'id', { |
| 83 | account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0', |
| 84 | }); |
| 85 | const rawResponse = await responsePromise.asResponse(); |
| 86 | expect(rawResponse).toBeInstanceOf(Response); |
| 87 | const response = await responsePromise; |
| 88 | expect(response).not.toBeInstanceOf(Response); |
| 89 | const dataAndResponse = await responsePromise.withResponse(); |
| 90 | expect(dataAndResponse.data).toBe(response); |
| 91 | expect(dataAndResponse.response).toBe(rawResponse); |
| 92 | }); |
| 93 | |
| 94 | test('get: required and optional params', async () => { |
| 95 | const response = await client.aiGateway.evaluations.get('my-gateway', 'id', { |
| 96 | account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0', |
| 97 | }); |
| 98 | }); |
| 99 | }); |
| 100 | |