cloudflare/cloudflare-typescript

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
045f10cd3c9bf56be38441a1850c169903794655

Branches

Tags

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

Clone

HTTPS

Download ZIP

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

43lines · 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 cache', () => {
16 // skipped: tests are disabled for the time being
17 test.skip('purge: only required params', async () => {
18 const responsePromise = cloudflare.cache.purge({ zone_id: 'string' });
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('purge: required and optional params', async () => {
30 const response = await cloudflare.cache.purge({
31 zone_id: 'string',
32 files: [
33 'http://www.example.com/css/styles.css',
34 'http://www.example.com/css/styles.css',
35 'http://www.example.com/css/styles.css',
36 ],
37 hosts: ['www.example.com', 'images.example.com'],
38 prefixes: ['www.example.com/foo', 'images.example.com/bar/baz'],
39 purge_everything: true,
40 tags: ['some-tag', 'another-tag'],
41 });
42 });
43});
44