cloudflare/cloudflare-typescript

Public

mirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
jacobbednarz-patch-1

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

tests/api-resources/access/custom-pages.test.ts

150lines · modecode

1// File generated from our OpenAPI spec by Stainless.
2
3import Cloudflare from 'cloudflare';
4import { Response } from 'node-fetch';
5
6const 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
14describe('resource customPages', () => {
15 // skipped: tests are disabled for the time being
16 test.skip('create: only required params', async () => {
17 const responsePromise = cloudflare.access.customPages.create('023e105f4ecef8ad9ca31a8372d0c353', {
18 custom_html: '<html><body><h1>Access Denied</h1></body></html>',
19 name: 'string',
20 type: 'identity_denied',
21 });
22 const rawResponse = await responsePromise.asResponse();
23 expect(rawResponse).toBeInstanceOf(Response);
24 const response = await responsePromise;
25 expect(response).not.toBeInstanceOf(Response);
26 const dataAndResponse = await responsePromise.withResponse();
27 expect(dataAndResponse.data).toBe(response);
28 expect(dataAndResponse.response).toBe(rawResponse);
29 });
30
31 // skipped: tests are disabled for the time being
32 test.skip('create: required and optional params', async () => {
33 const response = await cloudflare.access.customPages.create('023e105f4ecef8ad9ca31a8372d0c353', {
34 custom_html: '<html><body><h1>Access Denied</h1></body></html>',
35 name: 'string',
36 type: 'identity_denied',
37 app_count: 0,
38 });
39 });
40
41 // skipped: tests are disabled for the time being
42 test.skip('retrieve', async () => {
43 const responsePromise = cloudflare.access.customPages.retrieve(
44 '023e105f4ecef8ad9ca31a8372d0c353',
45 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
46 );
47 const rawResponse = await responsePromise.asResponse();
48 expect(rawResponse).toBeInstanceOf(Response);
49 const response = await responsePromise;
50 expect(response).not.toBeInstanceOf(Response);
51 const dataAndResponse = await responsePromise.withResponse();
52 expect(dataAndResponse.data).toBe(response);
53 expect(dataAndResponse.response).toBe(rawResponse);
54 });
55
56 // skipped: tests are disabled for the time being
57 test.skip('retrieve: request options instead of params are passed correctly', async () => {
58 // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
59 await expect(
60 cloudflare.access.customPages.retrieve(
61 '023e105f4ecef8ad9ca31a8372d0c353',
62 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
63 { path: '/_stainless_unknown_path' },
64 ),
65 ).rejects.toThrow(Cloudflare.NotFoundError);
66 });
67
68 // skipped: tests are disabled for the time being
69 test.skip('update: only required params', async () => {
70 const responsePromise = cloudflare.access.customPages.update(
71 '023e105f4ecef8ad9ca31a8372d0c353',
72 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
73 {
74 custom_html: '<html><body><h1>Access Denied</h1></body></html>',
75 name: 'string',
76 type: 'identity_denied',
77 },
78 );
79 const rawResponse = await responsePromise.asResponse();
80 expect(rawResponse).toBeInstanceOf(Response);
81 const response = await responsePromise;
82 expect(response).not.toBeInstanceOf(Response);
83 const dataAndResponse = await responsePromise.withResponse();
84 expect(dataAndResponse.data).toBe(response);
85 expect(dataAndResponse.response).toBe(rawResponse);
86 });
87
88 // skipped: tests are disabled for the time being
89 test.skip('update: required and optional params', async () => {
90 const response = await cloudflare.access.customPages.update(
91 '023e105f4ecef8ad9ca31a8372d0c353',
92 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
93 {
94 custom_html: '<html><body><h1>Access Denied</h1></body></html>',
95 name: 'string',
96 type: 'identity_denied',
97 app_count: 0,
98 },
99 );
100 });
101
102 // skipped: tests are disabled for the time being
103 test.skip('list', async () => {
104 const responsePromise = cloudflare.access.customPages.list('023e105f4ecef8ad9ca31a8372d0c353');
105 const rawResponse = await responsePromise.asResponse();
106 expect(rawResponse).toBeInstanceOf(Response);
107 const response = await responsePromise;
108 expect(response).not.toBeInstanceOf(Response);
109 const dataAndResponse = await responsePromise.withResponse();
110 expect(dataAndResponse.data).toBe(response);
111 expect(dataAndResponse.response).toBe(rawResponse);
112 });
113
114 // skipped: tests are disabled for the time being
115 test.skip('list: request options instead of params are passed correctly', async () => {
116 // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
117 await expect(
118 cloudflare.access.customPages.list('023e105f4ecef8ad9ca31a8372d0c353', {
119 path: '/_stainless_unknown_path',
120 }),
121 ).rejects.toThrow(Cloudflare.NotFoundError);
122 });
123
124 // skipped: tests are disabled for the time being
125 test.skip('delete', async () => {
126 const responsePromise = cloudflare.access.customPages.delete(
127 '023e105f4ecef8ad9ca31a8372d0c353',
128 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
129 );
130 const rawResponse = await responsePromise.asResponse();
131 expect(rawResponse).toBeInstanceOf(Response);
132 const response = await responsePromise;
133 expect(response).not.toBeInstanceOf(Response);
134 const dataAndResponse = await responsePromise.withResponse();
135 expect(dataAndResponse.data).toBe(response);
136 expect(dataAndResponse.response).toBe(rawResponse);
137 });
138
139 // skipped: tests are disabled for the time being
140 test.skip('delete: request options instead of params are passed correctly', async () => {
141 // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
142 await expect(
143 cloudflare.access.customPages.delete(
144 '023e105f4ecef8ad9ca31a8372d0c353',
145 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
146 { path: '/_stainless_unknown_path' },
147 ),
148 ).rejects.toThrow(Cloudflare.NotFoundError);
149 });
150});
151