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-gateway/evaluation-types.test.ts

55lines · modecode

1// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
3import { AIGateway } from 'cloudflare/resources/ai-gateway/ai-gateway';
4import { BaseEvaluationTypes } from 'cloudflare/resources/ai-gateway/evaluation-types';
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: [BaseEvaluationTypes],
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: [AIGateway],
27});
28
29const runTests = (client: PartialCloudflare<{ aiGateway: { evaluationTypes: BaseEvaluationTypes } }>) => {
30 test('list: only required params', async () => {
31 const responsePromise = client.aiGateway.evaluationTypes.list({
32 account_id: '0d37909e38d3e99c29fa2cd343ac421a',
33 });
34 const rawResponse = await responsePromise.asResponse();
35 expect(rawResponse).toBeInstanceOf(Response);
36 const response = await responsePromise;
37 expect(response).not.toBeInstanceOf(Response);
38 const dataAndResponse = await responsePromise.withResponse();
39 expect(dataAndResponse.data).toBe(response);
40 expect(dataAndResponse.response).toBe(rawResponse);
41 });
42
43 test('list: required and optional params', async () => {
44 const response = await client.aiGateway.evaluationTypes.list({
45 account_id: '0d37909e38d3e99c29fa2cd343ac421a',
46 order_by: 'order_by',
47 order_by_direction: 'asc',
48 page: 1,
49 per_page: 5,
50 });
51 });
52};
53describe('resource evaluationTypes', () => runTests(client));
54describe('resource evaluationTypes (tree shakable, base)', () => runTests(partialClient));
55describe('resource evaluationTypes (tree shakable, subresource)', () => runTests(parentPartialClient));
56