cloudflare/cloudflare-typescript

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v3.3.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

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

30lines · 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 cache', () => {
13 test('purge: only required params', async () => {
14 const responsePromise = cloudflare.cache.purge({ zone_id: 'string' });
15 const rawResponse = await responsePromise.asResponse();
16 expect(rawResponse).toBeInstanceOf(Response);
17 const response = await responsePromise;
18 expect(response).not.toBeInstanceOf(Response);
19 const dataAndResponse = await responsePromise.withResponse();
20 expect(dataAndResponse.data).toBe(response);
21 expect(dataAndResponse.response).toBe(rawResponse);
22 });
23
24 test('purge: required and optional params', async () => {
25 const response = await cloudflare.cache.purge({
26 zone_id: 'string',
27 tags: ['a-cache-tag', 'another-cache-tag'],
28 });
29 });
30});
31