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/ai-security/custom-topics.test.ts

75lines · modecode

1// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
3import { AISecurity } from 'cloudflare/resources/ai-security/ai-security';
4import { BaseCustomTopics } from 'cloudflare/resources/ai-security/custom-topics';
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: [BaseCustomTopics],
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: [AISecurity],
27});
28
29const runTests = (client: PartialCloudflare<{ aiSecurity: { customTopics: BaseCustomTopics } }>) => {
30 // HTTP 404 error from prism
31 test.skip('update: only required params', async () => {
32 const responsePromise = client.aiSecurity.customTopics.update({
33 zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
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 // HTTP 404 error from prism
45 test.skip('update: required and optional params', async () => {
46 const response = await client.aiSecurity.customTopics.update({
47 zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
48 topics: [{ label: 'credit-cards', topic: 'credit card numbers' }],
49 });
50 });
51
52 // HTTP 404 error from prism
53 test.skip('get: only required params', async () => {
54 const responsePromise = client.aiSecurity.customTopics.get({
55 zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
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 // HTTP 404 error from prism
67 test.skip('get: required and optional params', async () => {
68 const response = await client.aiSecurity.customTopics.get({
69 zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
70 });
71 });
72};
73describe('resource customTopics', () => runTests(client));
74describe('resource customTopics (tree shakable, base)', () => runTests(partialClient));
75describe('resource customTopics (tree shakable, subresource)', () => runTests(parentPartialClient));
76