cloudflare/cloudflare-typescript
Publicmirrored fromhttps://github.com/cloudflare/cloudflare-typescriptAvailable
tests/api-resources/api-gateway/schema-validation.test.ts
33lines · 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 cloudflare = 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 schemaValidation', () => { |
| 13 | test('edit: only required params', async () => { |
| 14 | const responsePromise = cloudflare.apiGateway.schemaValidation.edit({ |
| 15 | zone_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 16 | }); |
| 17 | const rawResponse = await responsePromise.asResponse(); |
| 18 | expect(rawResponse).toBeInstanceOf(Response); |
| 19 | const response = await responsePromise; |
| 20 | expect(response).not.toBeInstanceOf(Response); |
| 21 | const dataAndResponse = await responsePromise.withResponse(); |
| 22 | expect(dataAndResponse.data).toBe(response); |
| 23 | expect(dataAndResponse.response).toBe(rawResponse); |
| 24 | }); |
| 25 | |
| 26 | test('edit: required and optional params', async () => { |
| 27 | const response = await cloudflare.apiGateway.schemaValidation.edit({ |
| 28 | zone_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 29 | validation_default_mitigation_action: 'block', |
| 30 | validation_override_mitigation_action: 'none', |
| 31 | }); |
| 32 | }); |
| 33 | }); |
| 34 | |