cloudflare/cloudflare-typescript

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v7

Branches

Tags

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

Clone

HTTPS

Download ZIP

tests/api-resources/acm/total-tls.test.ts

91lines · modecode

1// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
3import { ACM } from 'cloudflare/resources/acm/acm';
4import { BaseTotalTLS } from 'cloudflare/resources/acm/total-tls';
5
6import Cloudflare from 'cloudflare';
7import { createClient, type PartialCloudflare } from 'cloudflare/tree-shakable';
8
9const client = new Cloudflare({
10 apiKey: '144c9defac04969c7bfad8efaa8ea194',
11 apiEmail: 'user@example.com',
12 baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
13});
14
15const partialClient = createClient({
16 apiKey: '144c9defac04969c7bfad8efaa8ea194',
17 apiEmail: 'user@example.com',
18 baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
19 resources: [BaseTotalTLS],
20});
21
22const parentPartialClient = createClient({
23 apiKey: '144c9defac04969c7bfad8efaa8ea194',
24 apiEmail: 'user@example.com',
25 baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
26 resources: [ACM],
27});
28
29const runTests = (client: PartialCloudflare<{ acm: { totalTLS: BaseTotalTLS } }>) => {
30 test('update: only required params', async () => {
31 const responsePromise = client.acm.totalTLS.update({
32 zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
33 enabled: true,
34 });
35 const rawResponse = await responsePromise.asResponse();
36 expect(rawResponse).toBeInstanceOf(Response);
37 const response = await responsePromise;
38 expect(response).not.toBeInstanceOf(Response);
39 const dataAndResponse = await responsePromise.withResponse();
40 expect(dataAndResponse.data).toBe(response);
41 expect(dataAndResponse.response).toBe(rawResponse);
42 });
43
44 test('update: required and optional params', async () => {
45 const response = await client.acm.totalTLS.update({
46 zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
47 enabled: true,
48 certificate_authority: 'google',
49 });
50 });
51
52 test('edit: only required params', async () => {
53 const responsePromise = client.acm.totalTLS.edit({
54 zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
55 enabled: true,
56 });
57 const rawResponse = await responsePromise.asResponse();
58 expect(rawResponse).toBeInstanceOf(Response);
59 const response = await responsePromise;
60 expect(response).not.toBeInstanceOf(Response);
61 const dataAndResponse = await responsePromise.withResponse();
62 expect(dataAndResponse.data).toBe(response);
63 expect(dataAndResponse.response).toBe(rawResponse);
64 });
65
66 test('edit: required and optional params', async () => {
67 const response = await client.acm.totalTLS.edit({
68 zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
69 enabled: true,
70 certificate_authority: 'google',
71 });
72 });
73
74 test('get: only required params', async () => {
75 const responsePromise = client.acm.totalTLS.get({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' });
76 const rawResponse = await responsePromise.asResponse();
77 expect(rawResponse).toBeInstanceOf(Response);
78 const response = await responsePromise;
79 expect(response).not.toBeInstanceOf(Response);
80 const dataAndResponse = await responsePromise.withResponse();
81 expect(dataAndResponse.data).toBe(response);
82 expect(dataAndResponse.response).toBe(rawResponse);
83 });
84
85 test('get: required and optional params', async () => {
86 const response = await client.acm.totalTLS.get({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' });
87 });
88};
89describe('resource totalTLS', () => runTests(client));
90describe('resource totalTLS (tree shakable, base)', () => runTests(partialClient));
91describe('resource totalTLS (tree shakable, subresource)', () => runTests(parentPartialClient));
92