Skip to main content
Glama
line-chart.test.ts1.8 kB
import { createLineChart } from '../charts/line-chart.js'; import { ChartData } from '../types/index.js'; describe('Line Chart', () => { test('should create basic line chart', () => { const data: ChartData = { data: [10, 20, 15, 25, 30], title: 'Test Line Chart', width: 40, height: 10, color: 'white' }; const result = createLineChart(data); expect(result.chart).toBeDefined(); expect(result.title).toBe('Test Line Chart'); expect(result.dimensions.width).toBe(40); expect(result.dimensions.height).toBe(10); expect(result.chart).toContain('●'); // Should contain data points }); test('should handle single data point', () => { const data: ChartData = { data: [42], width: 30, height: 8 }; const result = createLineChart(data); expect(result.chart).toBeDefined(); expect(result.chart).toContain('●'); }); test('should handle labels', () => { const data: ChartData = { data: [1, 2, 3, 4, 5], labels: ['A', 'B', 'C', 'D', 'E'], width: 50, height: 12 }; const result = createLineChart(data); expect(result.chart).toBeDefined(); expect(result.chart).toContain('A'); expect(result.chart).toContain('E'); }); test('should throw error for empty data', () => { const data: ChartData = { data: [], width: 30, height: 8 }; expect(() => createLineChart(data)).toThrow('Data array cannot be empty'); }); test('should handle flat data (all same values)', () => { const data: ChartData = { data: [5, 5, 5, 5, 5], width: 30, height: 8 }; const result = createLineChart(data); expect(result.chart).toBeDefined(); expect(result.chart).toContain('●'); }); });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/gianlucamazza/mcp-ascii-charts'

If you have feedback or need assistance with the MCP directory API, please join our Discord server