cloudflare/cloudflare-typescript

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v6.0.0-beta.1

Branches

Tags

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

Clone

HTTPS

Download ZIP

tests/api-resources/ai/to-markdown.test.ts

50lines · modecode

1// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
3import Cloudflare, { toFile } from 'cloudflare';
4import { Response } from 'node-fetch';
5
6const client = 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 toMarkdown', () => {
13 test('supported: only required params', async () => {
14 const responsePromise = client.ai.toMarkdown.supported({
15 account_id: '023e105f4ecef8ad9ca31a8372d0c353',
16 });
17 const rawResponse = await responsePromise.asResponse();
18 expect(rawResponse).toBeInstanceOf(Response);
19 const response = await responsePromise;
20 expect(response).not.toBeInstanceOf(Response);
21 const dataAndResponse = await responsePromise.withResponse();
22 expect(dataAndResponse.data).toBe(response);
23 expect(dataAndResponse.response).toBe(rawResponse);
24 });
25
26 test('supported: required and optional params', async () => {
27 const response = await client.ai.toMarkdown.supported({ account_id: '023e105f4ecef8ad9ca31a8372d0c353' });
28 });
29
30 test('transform: only required params', async () => {
31 const responsePromise = client.ai.toMarkdown.transform(
32 await toFile(Buffer.from('# my file contents'), 'README.md'),
33 { account_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 test('transform: required and optional params', async () => {
45 const response = await client.ai.toMarkdown.transform(
46 await toFile(Buffer.from('# my file contents'), 'README.md'),
47 { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
48 );
49 });
50});
51