cloudflare/cloudflare-typescript

Public

mirrored fromhttps://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/dispatchers/scripts.test.ts

77lines · 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 scripts', () => {
15 // skipped: tests are disabled for the time being
16 test.skip('retrieve', async () => {
17 const responsePromise = cloudflare.dispatchers.scripts.retrieve(
18 '023e105f4ecef8ad9ca31a8372d0c353',
19 'my-dispatch-namespace',
20 'this-is_my_script-01',
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('retrieve: request options instead of params are passed correctly', async () => {
33 // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
34 await expect(
35 cloudflare.dispatchers.scripts.retrieve(
36 '023e105f4ecef8ad9ca31a8372d0c353',
37 'my-dispatch-namespace',
38 'this-is_my_script-01',
39 { path: '/_stainless_unknown_path' },
40 ),
41 ).rejects.toThrow(Cloudflare.NotFoundError);
42 });
43
44 // skipped: tests are disabled for the time being
45 test.skip('update', async () => {
46 const responsePromise = cloudflare.dispatchers.scripts.update(
47 '023e105f4ecef8ad9ca31a8372d0c353',
48 'my-dispatch-namespace',
49 'this-is_my_script-01',
50 {},
51 );
52 const rawResponse = await responsePromise.asResponse();
53 expect(rawResponse).toBeInstanceOf(Response);
54 const response = await responsePromise;
55 expect(response).not.toBeInstanceOf(Response);
56 const dataAndResponse = await responsePromise.withResponse();
57 expect(dataAndResponse.data).toBe(response);
58 expect(dataAndResponse.response).toBe(rawResponse);
59 });
60
61 // skipped: tests are disabled for the time being
62 test.skip('delete', async () => {
63 const responsePromise = cloudflare.dispatchers.scripts.delete(
64 '023e105f4ecef8ad9ca31a8372d0c353',
65 'my-dispatch-namespace',
66 'this-is_my_script-01',
67 {},
68 );
69 const rawResponse = await responsePromise.asResponse();
70 expect(rawResponse).toBeInstanceOf(Response);
71 const response = await responsePromise;
72 expect(response).not.toBeInstanceOf(Response);
73 const dataAndResponse = await responsePromise.withResponse();
74 expect(dataAndResponse.data).toBe(response);
75 expect(dataAndResponse.response).toBe(rawResponse);
76 });
77});
78