cloudflare/cloudflare-typescript

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
52d0dde1b5384745b6077e2995c8e406ec275c87

Branches

Tags

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

Clone

HTTPS

Download ZIP

tests/api-resources/cache/variants.test.ts

84lines · 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: 'user@example.com',
9 apiToken: 'Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY',
10 userServiceKey:
11 'v1.0-144c9defac04969c7bfad8ef-631a41d003a32d25fe878081ef365c49503f7fada600da935e2851a1c7326084b85cbf6429c4b859de8475731dc92a9c329631e6d59e6c73da7b198497172b4cefe071d90d0f5d2719',
12 baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
13});
14
15describe('resource variants', () => {
16 // skipped: tests are disabled for the time being
17 test.skip('list: only required params', async () => {
18 const responsePromise = cloudflare.cache.variants.list({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' });
19 const rawResponse = await responsePromise.asResponse();
20 expect(rawResponse).toBeInstanceOf(Response);
21 const response = await responsePromise;
22 expect(response).not.toBeInstanceOf(Response);
23 const dataAndResponse = await responsePromise.withResponse();
24 expect(dataAndResponse.data).toBe(response);
25 expect(dataAndResponse.response).toBe(rawResponse);
26 });
27
28 // skipped: tests are disabled for the time being
29 test.skip('list: required and optional params', async () => {
30 const response = await cloudflare.cache.variants.list({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' });
31 });
32
33 // skipped: tests are disabled for the time being
34 test.skip('delete: only required params', async () => {
35 const responsePromise = cloudflare.cache.variants.delete({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' });
36 const rawResponse = await responsePromise.asResponse();
37 expect(rawResponse).toBeInstanceOf(Response);
38 const response = await responsePromise;
39 expect(response).not.toBeInstanceOf(Response);
40 const dataAndResponse = await responsePromise.withResponse();
41 expect(dataAndResponse.data).toBe(response);
42 expect(dataAndResponse.response).toBe(rawResponse);
43 });
44
45 // skipped: tests are disabled for the time being
46 test.skip('delete: required and optional params', async () => {
47 const response = await cloudflare.cache.variants.delete({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' });
48 });
49
50 // skipped: tests are disabled for the time being
51 test.skip('edit: only required params', async () => {
52 const responsePromise = cloudflare.cache.variants.edit({
53 zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
54 value: {},
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('edit: required and optional params', async () => {
67 const response = await cloudflare.cache.variants.edit({
68 zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
69 value: {
70 avif: ['image/webp', 'image/jpeg'],
71 bmp: ['image/webp', 'image/jpeg'],
72 gif: ['image/webp', 'image/jpeg'],
73 jp2: ['image/webp', 'image/avif'],
74 jpeg: ['image/webp', 'image/avif'],
75 jpg: ['image/webp', 'image/avif'],
76 jpg2: ['image/webp', 'image/avif'],
77 png: ['image/webp', 'image/avif'],
78 tif: ['image/webp', 'image/avif'],
79 tiff: ['image/webp', 'image/avif'],
80 webp: ['image/jpeg', 'image/avif'],
81 },
82 });
83 });
84});