cloudflare/cloudflare-typescript

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v3.1.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

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

87lines · 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({
16 zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
17 body: {},
18 });
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('delete: required and optional params', async () => {
30 const response = await cloudflare.cache.variants.delete({
31 zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
32 body: {},
33 });
34 });
35
36 // skipped: tests are disabled for the time being
37 test.skip('edit: only required params', async () => {
38 const responsePromise = cloudflare.cache.variants.edit({
39 zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
40 value: {},
41 });
42 const rawResponse = await responsePromise.asResponse();
43 expect(rawResponse).toBeInstanceOf(Response);
44 const response = await responsePromise;
45 expect(response).not.toBeInstanceOf(Response);
46 const dataAndResponse = await responsePromise.withResponse();
47 expect(dataAndResponse.data).toBe(response);
48 expect(dataAndResponse.response).toBe(rawResponse);
49 });
50
51 // skipped: tests are disabled for the time being
52 test.skip('edit: required and optional params', async () => {
53 const response = await cloudflare.cache.variants.edit({
54 zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
55 value: {
56 avif: ['image/webp', 'image/jpeg'],
57 bmp: ['image/webp', 'image/jpeg'],
58 gif: ['image/webp', 'image/jpeg'],
59 jp2: ['image/webp', 'image/avif'],
60 jpeg: ['image/webp', 'image/avif'],
61 jpg: ['image/webp', 'image/avif'],
62 jpg2: ['image/webp', 'image/avif'],
63 png: ['image/webp', 'image/avif'],
64 tif: ['image/webp', 'image/avif'],
65 tiff: ['image/webp', 'image/avif'],
66 webp: ['image/jpeg', 'image/avif'],
67 },
68 });
69 });
70
71 // skipped: tests are disabled for the time being
72 test.skip('get: only required params', async () => {
73 const responsePromise = cloudflare.cache.variants.get({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' });
74 const rawResponse = await responsePromise.asResponse();
75 expect(rawResponse).toBeInstanceOf(Response);
76 const response = await responsePromise;
77 expect(response).not.toBeInstanceOf(Response);
78 const dataAndResponse = await responsePromise.withResponse();
79 expect(dataAndResponse.data).toBe(response);
80 expect(dataAndResponse.response).toBe(rawResponse);
81 });
82
83 // skipped: tests are disabled for the time being
84 test.skip('get: required and optional params', async () => {
85 const response = await cloudflare.cache.variants.get({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' });
86 });
87});
88