cloudflare/cloudflare-typescript
Publicmirrored fromhttps://github.com/cloudflare/cloudflare-typescriptAvailable
tests/api-resources/api-gateway/configurations.test.ts
52lines · 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 configurations', () => { |
| 13 | test('update: only required params', async () => { |
| 14 | const responsePromise = cloudflare.apiGateway.configurations.update({ |
| 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('update: required and optional params', async () => { |
| 27 | const response = await cloudflare.apiGateway.configurations.update({ |
| 28 | zone_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 29 | auth_id_characteristics: [{ name: 'authorization', type: 'header' }], |
| 30 | }); |
| 31 | }); |
| 32 | |
| 33 | test('get: only required params', async () => { |
| 34 | const responsePromise = cloudflare.apiGateway.configurations.get({ |
| 35 | zone_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 36 | }); |
| 37 | const rawResponse = await responsePromise.asResponse(); |
| 38 | expect(rawResponse).toBeInstanceOf(Response); |
| 39 | const response = await responsePromise; |
| 40 | expect(response).not.toBeInstanceOf(Response); |
| 41 | const dataAndResponse = await responsePromise.withResponse(); |
| 42 | expect(dataAndResponse.data).toBe(response); |
| 43 | expect(dataAndResponse.response).toBe(rawResponse); |
| 44 | }); |
| 45 | |
| 46 | test('get: required and optional params', async () => { |
| 47 | const response = await cloudflare.apiGateway.configurations.get({ |
| 48 | zone_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 49 | properties: ['auth_id_characteristics'], |
| 50 | }); |
| 51 | }); |
| 52 | }); |
| 53 | |