cloudflare/cloudflare-typescript
Publicmirrored fromhttps://github.com/cloudflare/cloudflare-typescriptAvailable
tests/api-resources/addressing/services.test.ts
36lines · modecode
| 1 | // File generated from our OpenAPI spec by Stainless. |
| 2 | |
| 3 | import Cloudflare from 'cloudflare'; |
| 4 | import { Response } from 'node-fetch'; |
| 5 | |
| 6 | const cloudflare = new Cloudflare({ |
| 7 | apiKey: '144c9defac04969c7bfad8efaa8ea194', |
| 8 | apiEmail: 'dev@cloudflare.com', |
| 9 | apiToken: 'Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY', |
| 10 | userServiceKey: 'My User Service Key', |
| 11 | baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', |
| 12 | }); |
| 13 | |
| 14 | describe('resource services', () => { |
| 15 | // skipped: tests are disabled for the time being |
| 16 | test.skip('list', async () => { |
| 17 | const responsePromise = cloudflare.addressing.services.list('023e105f4ecef8ad9ca31a8372d0c353'); |
| 18 | const rawResponse = await responsePromise.asResponse(); |
| 19 | expect(rawResponse).toBeInstanceOf(Response); |
| 20 | const response = await responsePromise; |
| 21 | expect(response).not.toBeInstanceOf(Response); |
| 22 | const dataAndResponse = await responsePromise.withResponse(); |
| 23 | expect(dataAndResponse.data).toBe(response); |
| 24 | expect(dataAndResponse.response).toBe(rawResponse); |
| 25 | }); |
| 26 | |
| 27 | // skipped: tests are disabled for the time being |
| 28 | test.skip('list: request options instead of params are passed correctly', async () => { |
| 29 | // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error |
| 30 | await expect( |
| 31 | cloudflare.addressing.services.list('023e105f4ecef8ad9ca31a8372d0c353', { |
| 32 | path: '/_stainless_unknown_path', |
| 33 | }), |
| 34 | ).rejects.toThrow(Cloudflare.NotFoundError); |
| 35 | }); |
| 36 | }); |
| 37 | |