cloudflare/cloudflare-typescript

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
1df362c4fc2bfab889e57407ef29ae8df3e65122

Branches

Tags

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

Clone

HTTPS

Download ZIP

tests/api-resources/analytics/dashboards.test.ts

51lines · 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 dashboards', () => {
15 // skipped: tests are disabled for the time being
16 test.skip('zoneAnalyticsDeprecatedGetDashboard', async () => {
17 const responsePromise = cloudflare.analytics.dashboards.zoneAnalyticsDeprecatedGetDashboard(
18 '023e105f4ecef8ad9ca31a8372d0c353',
19 );
20 const rawResponse = await responsePromise.asResponse();
21 expect(rawResponse).toBeInstanceOf(Response);
22 const response = await responsePromise;
23 expect(response).not.toBeInstanceOf(Response);
24 const dataAndResponse = await responsePromise.withResponse();
25 expect(dataAndResponse.data).toBe(response);
26 expect(dataAndResponse.response).toBe(rawResponse);
27 });
28
29 // skipped: tests are disabled for the time being
30 test.skip('zoneAnalyticsDeprecatedGetDashboard: request options instead of params are passed correctly', async () => {
31 // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
32 await expect(
33 cloudflare.analytics.dashboards.zoneAnalyticsDeprecatedGetDashboard(
34 '023e105f4ecef8ad9ca31a8372d0c353',
35 { path: '/_stainless_unknown_path' },
36 ),
37 ).rejects.toThrow(Cloudflare.NotFoundError);
38 });
39
40 // skipped: tests are disabled for the time being
41 test.skip('zoneAnalyticsDeprecatedGetDashboard: request options and params are passed correctly', async () => {
42 // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
43 await expect(
44 cloudflare.analytics.dashboards.zoneAnalyticsDeprecatedGetDashboard(
45 '023e105f4ecef8ad9ca31a8372d0c353',
46 { continuous: true, since: '2015-01-01T12:23:00Z', until: '2015-01-02T12:23:00Z' },
47 { path: '/_stainless_unknown_path' },
48 ),
49 ).rejects.toThrow(Cloudflare.NotFoundError);
50 });
51});
52