cloudflare/cloudflare-typescript
Publicmirrored fromhttps://github.com/cloudflare/cloudflare-typescriptAvailable
tests/api-resources/challenges/widgets.test.ts
166lines · 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: 'user@example.com', |
| 9 | baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', |
| 10 | }); |
| 11 | |
| 12 | describe('resource widgets', () => { |
| 13 | // skipped: tests are disabled for the time being |
| 14 | test.skip('create: only required params', async () => { |
| 15 | const responsePromise = cloudflare.challenges.widgets.create({ |
| 16 | account_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 17 | domains: ['203.0.113.1', 'cloudflare.com', 'blog.example.com'], |
| 18 | mode: 'invisible', |
| 19 | name: 'blog.cloudflare.com login form', |
| 20 | }); |
| 21 | const rawResponse = await responsePromise.asResponse(); |
| 22 | expect(rawResponse).toBeInstanceOf(Response); |
| 23 | const response = await responsePromise; |
| 24 | expect(response).not.toBeInstanceOf(Response); |
| 25 | const dataAndResponse = await responsePromise.withResponse(); |
| 26 | expect(dataAndResponse.data).toBe(response); |
| 27 | expect(dataAndResponse.response).toBe(rawResponse); |
| 28 | }); |
| 29 | |
| 30 | // skipped: tests are disabled for the time being |
| 31 | test.skip('create: required and optional params', async () => { |
| 32 | const response = await cloudflare.challenges.widgets.create({ |
| 33 | account_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 34 | domains: ['203.0.113.1', 'cloudflare.com', 'blog.example.com'], |
| 35 | mode: 'invisible', |
| 36 | name: 'blog.cloudflare.com login form', |
| 37 | direction: 'asc', |
| 38 | order: 'id', |
| 39 | page: 1, |
| 40 | per_page: 5, |
| 41 | bot_fight_mode: false, |
| 42 | clearance_level: 'interactive', |
| 43 | offlabel: false, |
| 44 | region: 'world', |
| 45 | }); |
| 46 | }); |
| 47 | |
| 48 | // skipped: tests are disabled for the time being |
| 49 | test.skip('update: only required params', async () => { |
| 50 | const responsePromise = cloudflare.challenges.widgets.update('0x4AAF00AAAABn0R22HWm-YUc', { |
| 51 | account_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 52 | domains: ['203.0.113.1', 'cloudflare.com', 'blog.example.com'], |
| 53 | mode: 'invisible', |
| 54 | name: 'blog.cloudflare.com login form', |
| 55 | }); |
| 56 | const rawResponse = await responsePromise.asResponse(); |
| 57 | expect(rawResponse).toBeInstanceOf(Response); |
| 58 | const response = await responsePromise; |
| 59 | expect(response).not.toBeInstanceOf(Response); |
| 60 | const dataAndResponse = await responsePromise.withResponse(); |
| 61 | expect(dataAndResponse.data).toBe(response); |
| 62 | expect(dataAndResponse.response).toBe(rawResponse); |
| 63 | }); |
| 64 | |
| 65 | // skipped: tests are disabled for the time being |
| 66 | test.skip('update: required and optional params', async () => { |
| 67 | const response = await cloudflare.challenges.widgets.update('0x4AAF00AAAABn0R22HWm-YUc', { |
| 68 | account_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 69 | domains: ['203.0.113.1', 'cloudflare.com', 'blog.example.com'], |
| 70 | mode: 'invisible', |
| 71 | name: 'blog.cloudflare.com login form', |
| 72 | bot_fight_mode: false, |
| 73 | clearance_level: 'interactive', |
| 74 | offlabel: false, |
| 75 | }); |
| 76 | }); |
| 77 | |
| 78 | // skipped: tests are disabled for the time being |
| 79 | test.skip('list: only required params', async () => { |
| 80 | const responsePromise = cloudflare.challenges.widgets.list({ |
| 81 | account_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 82 | }); |
| 83 | const rawResponse = await responsePromise.asResponse(); |
| 84 | expect(rawResponse).toBeInstanceOf(Response); |
| 85 | const response = await responsePromise; |
| 86 | expect(response).not.toBeInstanceOf(Response); |
| 87 | const dataAndResponse = await responsePromise.withResponse(); |
| 88 | expect(dataAndResponse.data).toBe(response); |
| 89 | expect(dataAndResponse.response).toBe(rawResponse); |
| 90 | }); |
| 91 | |
| 92 | // skipped: tests are disabled for the time being |
| 93 | test.skip('list: required and optional params', async () => { |
| 94 | const response = await cloudflare.challenges.widgets.list({ |
| 95 | account_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 96 | direction: 'asc', |
| 97 | order: 'id', |
| 98 | page: 1, |
| 99 | per_page: 5, |
| 100 | }); |
| 101 | }); |
| 102 | |
| 103 | // skipped: tests are disabled for the time being |
| 104 | test.skip('delete: only required params', async () => { |
| 105 | const responsePromise = cloudflare.challenges.widgets.delete('0x4AAF00AAAABn0R22HWm-YUc', { |
| 106 | account_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 107 | }); |
| 108 | const rawResponse = await responsePromise.asResponse(); |
| 109 | expect(rawResponse).toBeInstanceOf(Response); |
| 110 | const response = await responsePromise; |
| 111 | expect(response).not.toBeInstanceOf(Response); |
| 112 | const dataAndResponse = await responsePromise.withResponse(); |
| 113 | expect(dataAndResponse.data).toBe(response); |
| 114 | expect(dataAndResponse.response).toBe(rawResponse); |
| 115 | }); |
| 116 | |
| 117 | // skipped: tests are disabled for the time being |
| 118 | test.skip('delete: required and optional params', async () => { |
| 119 | const response = await cloudflare.challenges.widgets.delete('0x4AAF00AAAABn0R22HWm-YUc', { |
| 120 | account_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 121 | }); |
| 122 | }); |
| 123 | |
| 124 | // skipped: tests are disabled for the time being |
| 125 | test.skip('get: only required params', async () => { |
| 126 | const responsePromise = cloudflare.challenges.widgets.get('0x4AAF00AAAABn0R22HWm-YUc', { |
| 127 | account_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 128 | }); |
| 129 | const rawResponse = await responsePromise.asResponse(); |
| 130 | expect(rawResponse).toBeInstanceOf(Response); |
| 131 | const response = await responsePromise; |
| 132 | expect(response).not.toBeInstanceOf(Response); |
| 133 | const dataAndResponse = await responsePromise.withResponse(); |
| 134 | expect(dataAndResponse.data).toBe(response); |
| 135 | expect(dataAndResponse.response).toBe(rawResponse); |
| 136 | }); |
| 137 | |
| 138 | // skipped: tests are disabled for the time being |
| 139 | test.skip('get: required and optional params', async () => { |
| 140 | const response = await cloudflare.challenges.widgets.get('0x4AAF00AAAABn0R22HWm-YUc', { |
| 141 | account_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 142 | }); |
| 143 | }); |
| 144 | |
| 145 | // skipped: tests are disabled for the time being |
| 146 | test.skip('rotateSecret: only required params', async () => { |
| 147 | const responsePromise = cloudflare.challenges.widgets.rotateSecret('0x4AAF00AAAABn0R22HWm-YUc', { |
| 148 | account_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 149 | }); |
| 150 | const rawResponse = await responsePromise.asResponse(); |
| 151 | expect(rawResponse).toBeInstanceOf(Response); |
| 152 | const response = await responsePromise; |
| 153 | expect(response).not.toBeInstanceOf(Response); |
| 154 | const dataAndResponse = await responsePromise.withResponse(); |
| 155 | expect(dataAndResponse.data).toBe(response); |
| 156 | expect(dataAndResponse.response).toBe(rawResponse); |
| 157 | }); |
| 158 | |
| 159 | // skipped: tests are disabled for the time being |
| 160 | test.skip('rotateSecret: required and optional params', async () => { |
| 161 | const response = await cloudflare.challenges.widgets.rotateSecret('0x4AAF00AAAABn0R22HWm-YUc', { |
| 162 | account_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 163 | invalidate_immediately: true, |
| 164 | }); |
| 165 | }); |
| 166 | }); |
| 167 | |