cloudflare/cloudflare-typescript
Publicmirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable
tests/api-resources/access/bookmarks.test.ts
93lines · 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 bookmarks', () => { |
| 15 | // skipped: tests are disabled for the time being |
| 16 | test.skip('list', async () => { |
| 17 | const responsePromise = cloudflare.access.bookmarks.list('699d98642c564d2e855e9661899b7252'); |
| 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.access.bookmarks.list('699d98642c564d2e855e9661899b7252', { |
| 32 | path: '/_stainless_unknown_path', |
| 33 | }), |
| 34 | ).rejects.toThrow(Cloudflare.NotFoundError); |
| 35 | }); |
| 36 | |
| 37 | // skipped: tests are disabled for the time being |
| 38 | test.skip('delete', async () => { |
| 39 | const responsePromise = cloudflare.access.bookmarks.delete( |
| 40 | '699d98642c564d2e855e9661899b7252', |
| 41 | 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', |
| 42 | ); |
| 43 | const rawResponse = await responsePromise.asResponse(); |
| 44 | expect(rawResponse).toBeInstanceOf(Response); |
| 45 | const response = await responsePromise; |
| 46 | expect(response).not.toBeInstanceOf(Response); |
| 47 | const dataAndResponse = await responsePromise.withResponse(); |
| 48 | expect(dataAndResponse.data).toBe(response); |
| 49 | expect(dataAndResponse.response).toBe(rawResponse); |
| 50 | }); |
| 51 | |
| 52 | // skipped: tests are disabled for the time being |
| 53 | test.skip('get', async () => { |
| 54 | const responsePromise = cloudflare.access.bookmarks.get( |
| 55 | '699d98642c564d2e855e9661899b7252', |
| 56 | 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', |
| 57 | ); |
| 58 | const rawResponse = await responsePromise.asResponse(); |
| 59 | expect(rawResponse).toBeInstanceOf(Response); |
| 60 | const response = await responsePromise; |
| 61 | expect(response).not.toBeInstanceOf(Response); |
| 62 | const dataAndResponse = await responsePromise.withResponse(); |
| 63 | expect(dataAndResponse.data).toBe(response); |
| 64 | expect(dataAndResponse.response).toBe(rawResponse); |
| 65 | }); |
| 66 | |
| 67 | // skipped: tests are disabled for the time being |
| 68 | test.skip('get: request options instead of params are passed correctly', async () => { |
| 69 | // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error |
| 70 | await expect( |
| 71 | cloudflare.access.bookmarks.get( |
| 72 | '699d98642c564d2e855e9661899b7252', |
| 73 | 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', |
| 74 | { path: '/_stainless_unknown_path' }, |
| 75 | ), |
| 76 | ).rejects.toThrow(Cloudflare.NotFoundError); |
| 77 | }); |
| 78 | |
| 79 | // skipped: tests are disabled for the time being |
| 80 | test.skip('replace', async () => { |
| 81 | const responsePromise = cloudflare.access.bookmarks.replace( |
| 82 | '699d98642c564d2e855e9661899b7252', |
| 83 | 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', |
| 84 | ); |
| 85 | const rawResponse = await responsePromise.asResponse(); |
| 86 | expect(rawResponse).toBeInstanceOf(Response); |
| 87 | const response = await responsePromise; |
| 88 | expect(response).not.toBeInstanceOf(Response); |
| 89 | const dataAndResponse = await responsePromise.withResponse(); |
| 90 | expect(dataAndResponse.data).toBe(response); |
| 91 | expect(dataAndResponse.response).toBe(rawResponse); |
| 92 | }); |
| 93 | }); |
| 94 | |