cloudflare/cloudflare-typescript

Public

mirrored fromhttps://github.com/cloudflare/cloudflare-typescriptAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v3.0.0-beta.14

Branches

Tags

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

Clone

HTTPS

Download ZIP

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

81lines · modecode

1// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
3import Cloudflare from 'cloudflare';
4import { Response } from 'node-fetch';
5
6const cloudflare = new Cloudflare({
7 apiKey: '144c9defac04969c7bfad8efaa8ea194',
8 apiEmail: 'user@example.com',
9 baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
10});
11
12describe('resource variants', () => {
13 // skipped: tests are disabled for the time being
14 test.skip('delete: only required params', async () => {
15 const responsePromise = cloudflare.cache.variants.delete({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' });
16 const rawResponse = await responsePromise.asResponse();
17 expect(rawResponse).toBeInstanceOf(Response);
18 const response = await responsePromise;
19 expect(response).not.toBeInstanceOf(Response);
20 const dataAndResponse = await responsePromise.withResponse();
21 expect(dataAndResponse.data).toBe(response);
22 expect(dataAndResponse.response).toBe(rawResponse);
23 });
24
25 // skipped: tests are disabled for the time being
26 test.skip('delete: required and optional params', async () => {
27 const response = await cloudflare.cache.variants.delete({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' });
28 });
29
30 // skipped: tests are disabled for the time being
31 test.skip('edit: only required params', async () => {
32 const responsePromise = cloudflare.cache.variants.edit({
33 zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
34 value: {},
35 });
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('edit: required and optional params', async () => {
47 const response = await cloudflare.cache.variants.edit({
48 zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
49 value: {
50 avif: ['image/webp', 'image/jpeg'],
51 bmp: ['image/webp', 'image/jpeg'],
52 gif: ['image/webp', 'image/jpeg'],
53 jp2: ['image/webp', 'image/avif'],
54 jpeg: ['image/webp', 'image/avif'],
55 jpg: ['image/webp', 'image/avif'],
56 jpg2: ['image/webp', 'image/avif'],
57 png: ['image/webp', 'image/avif'],
58 tif: ['image/webp', 'image/avif'],
59 tiff: ['image/webp', 'image/avif'],
60 webp: ['image/jpeg', 'image/avif'],
61 },
62 });
63 });
64
65 // skipped: tests are disabled for the time being
66 test.skip('get: only required params', async () => {
67 const responsePromise = cloudflare.cache.variants.get({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' });
68 const rawResponse = await responsePromise.asResponse();
69 expect(rawResponse).toBeInstanceOf(Response);
70 const response = await responsePromise;
71 expect(response).not.toBeInstanceOf(Response);
72 const dataAndResponse = await responsePromise.withResponse();
73 expect(dataAndResponse.data).toBe(response);
74 expect(dataAndResponse.response).toBe(rawResponse);
75 });
76
77 // skipped: tests are disabled for the time being
78 test.skip('get: required and optional params', async () => {
79 const response = await cloudflare.cache.variants.get({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' });
80 });
81});
82