cloudflare/cloudflare-typescript
Publicmirrored fromhttps://github.com/cloudflare/cloudflare-typescriptAvailable
tests/api-resources/ai-security/ai-security.test.ts
60lines · modecode
| 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | |
| 3 | import { BaseAISecurity } from 'cloudflare/resources/ai-security/ai-security'; |
| 4 | |
| 5 | import Cloudflare from 'cloudflare'; |
| 6 | import { createClient, type PartialCloudflare } from 'cloudflare/tree-shakable'; |
| 7 | |
| 8 | const client = new Cloudflare({ |
| 9 | apiKey: '144c9defac04969c7bfad8efaa8ea194', |
| 10 | apiEmail: 'user@example.com', |
| 11 | baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', |
| 12 | }); |
| 13 | |
| 14 | const partialClient = createClient({ |
| 15 | apiKey: '144c9defac04969c7bfad8efaa8ea194', |
| 16 | apiEmail: 'user@example.com', |
| 17 | baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', |
| 18 | resources: [BaseAISecurity], |
| 19 | }); |
| 20 | |
| 21 | const runTests = (client: PartialCloudflare<{ aiSecurity: BaseAISecurity }>) => { |
| 22 | // HTTP 404 error from prism |
| 23 | test.skip('update: only required params', async () => { |
| 24 | const responsePromise = client.aiSecurity.update({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }); |
| 25 | const rawResponse = await responsePromise.asResponse(); |
| 26 | expect(rawResponse).toBeInstanceOf(Response); |
| 27 | const response = await responsePromise; |
| 28 | expect(response).not.toBeInstanceOf(Response); |
| 29 | const dataAndResponse = await responsePromise.withResponse(); |
| 30 | expect(dataAndResponse.data).toBe(response); |
| 31 | expect(dataAndResponse.response).toBe(rawResponse); |
| 32 | }); |
| 33 | |
| 34 | // HTTP 404 error from prism |
| 35 | test.skip('update: required and optional params', async () => { |
| 36 | const response = await client.aiSecurity.update({ |
| 37 | zone_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 38 | enabled: true, |
| 39 | }); |
| 40 | }); |
| 41 | |
| 42 | // HTTP 404 error from prism |
| 43 | test.skip('get: only required params', async () => { |
| 44 | const responsePromise = client.aiSecurity.get({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }); |
| 45 | const rawResponse = await responsePromise.asResponse(); |
| 46 | expect(rawResponse).toBeInstanceOf(Response); |
| 47 | const response = await responsePromise; |
| 48 | expect(response).not.toBeInstanceOf(Response); |
| 49 | const dataAndResponse = await responsePromise.withResponse(); |
| 50 | expect(dataAndResponse.data).toBe(response); |
| 51 | expect(dataAndResponse.response).toBe(rawResponse); |
| 52 | }); |
| 53 | |
| 54 | // HTTP 404 error from prism |
| 55 | test.skip('get: required and optional params', async () => { |
| 56 | const response = await client.aiSecurity.get({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }); |
| 57 | }); |
| 58 | }; |
| 59 | describe('resource aiSecurity', () => runTests(client)); |
| 60 | describe('resource aiSecurity (tree shakable, base)', () => runTests(partialClient)); |
| 61 | |