cloudflare/cloudflare-typescript
Publicmirrored fromhttps://github.com/cloudflare/cloudflare-typescriptAvailable
tests/api-resources/accounts/roles.test.ts
50lines · 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 roles', () => { |
| 13 | test('list: only required params', async () => { |
| 14 | const responsePromise = cloudflare.accounts.roles.list({ |
| 15 | account_id: 'eb78d65290b24279ba6f44721b3ea3c4', |
| 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('list: required and optional params', async () => { |
| 27 | const response = await cloudflare.accounts.roles.list({ account_id: 'eb78d65290b24279ba6f44721b3ea3c4' }); |
| 28 | }); |
| 29 | |
| 30 | test('get: only required params', async () => { |
| 31 | const responsePromise = cloudflare.accounts.roles.get( |
| 32 | {}, |
| 33 | { account_id: 'eb78d65290b24279ba6f44721b3ea3c4' }, |
| 34 | ); |
| 35 | const rawResponse = await responsePromise.asResponse(); |
| 36 | expect(rawResponse).toBeInstanceOf(Response); |
| 37 | const response = await responsePromise; |
| 38 | expect(response).not.toBeInstanceOf(Response); |
| 39 | const dataAndResponse = await responsePromise.withResponse(); |
| 40 | expect(dataAndResponse.data).toBe(response); |
| 41 | expect(dataAndResponse.response).toBe(rawResponse); |
| 42 | }); |
| 43 | |
| 44 | test('get: required and optional params', async () => { |
| 45 | const response = await cloudflare.accounts.roles.get( |
| 46 | {}, |
| 47 | { account_id: 'eb78d65290b24279ba6f44721b3ea3c4' }, |
| 48 | ); |
| 49 | }); |
| 50 | }); |