UNPKG

ai-functions

Version:

A powerful TypeScript library for building AI-powered applications with template literals and structured outputs

31 lines 1.33 kB
import { describe, expect, it } from 'vitest'; import { createJsonResponse, createStreamResponse, createTextResponse } from './responses'; describe('Response Creation', () => { it('should create JSON response', () => { const mockResult = { text: 'test content', response: { id: 'test', model: 'test-model', created: 123 } }; const response = createJsonResponse(mockResult); expect(response).toBeInstanceOf(Response); expect(response.headers.get('Content-Type')).toBe('application/json'); }); it('should create stream response', () => { const mockResult = { experimental_stream: new ReadableStream() }; const response = createStreamResponse(mockResult); expect(response).toBeInstanceOf(Response); expect(response.headers.get('Content-Type')).toBe('text/event-stream'); }); it('should create text response', () => { const mockResult = { text: 'test content', response: { id: 'test', model: 'test-model', created: 123 } }; const response = createTextResponse(mockResult); expect(response).toBeInstanceOf(Response); expect(response.headers.get('Content-Type')).toBe('text/plain'); }); }); //# sourceMappingURL=responses.test.js.map