UNPKG

@2501-ai/cli

Version:

[![npm version](https://img.shields.io/npm/v/@2501-ai/cli.svg)](https://www.npmjs.com/package/@2501-ai/cli) [![HumanEval Score](https://img.shields.io/badge/HumanEval-96.95%25-brightgreen.svg)](https://www.2501.ai/research/full-humaneval-benchmark) [![Lic

55 lines (54 loc) 2.59 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const windowsHelper_1 = require("../windowsHelper"); describe('sanitizeWindowsOutput', () => { it('should normalize CRLF to LF', () => { const input = '{\r\n "foo": 1\r\n}'; expect((0, windowsHelper_1.sanitizeWindowsOutput)(input)).toBe('{\n "foo": 1\n}'); }); it('should normalize standalone CR to LF', () => { expect((0, windowsHelper_1.sanitizeWindowsOutput)('line1\rline2')).toBe('line1\nline2'); }); it('should remove null bytes and other junk', () => { expect((0, windowsHelper_1.sanitizeWindowsOutput)('hello\u0000world')).toBe('helloworld'); }); it('should preserve tabs and newlines', () => { expect((0, windowsHelper_1.sanitizeWindowsOutput)('col1\tcol2\nrow2')).toBe('col1\tcol2\nrow2'); }); it('should produce valid JSON from PowerShell output', () => { const psOutput = '{\r\n "PostgreSQL": 4,\r\n "Celery": true\r\n}'; const result = (0, windowsHelper_1.sanitizeWindowsOutput)(psOutput); expect(() => JSON.parse(result)).not.toThrow(); }); it('should sanitize PowerShell ConvertTo-Json output', () => { const psOutput = '{\r\n "PostgreSQL": 4,\r\n "Celery": true,\r\n "RabbitMQ": 4,\r\n "Flower": 4\r\n}'; const result = (0, windowsHelper_1.sanitizeWindowsOutput)(psOutput); console.log(result); expect(result).not.toContain('\r\n'); expect(result).not.toContain('\r'); expect(result).toContain('\n'); expect(() => JSON.parse(result)).not.toThrow(); const parsed = JSON.parse(result); expect(parsed).toEqual({ PostgreSQL: 4, Celery: true, RabbitMQ: 4, Flower: 4, }); }); it('should handle mixed escaped/unescaped line endings', () => { const weirdOutput = '{\\\r\n "test": 1\\\r\n}'; expect(() => JSON.parse(weirdOutput)).toThrow(); const result = (0, windowsHelper_1.sanitizeWindowsOutput)(weirdOutput); expect(result).not.toContain('\r'); expect(result).toContain('\n'); }); }); describe('isCommandNotFound', () => { it('should detect "not recognized" errors', () => { expect((0, windowsHelper_1.isCommandNotFound)("'foo' is not recognized as an internal or external command")).toBe(true); }); it('should return false for valid output', () => { expect((0, windowsHelper_1.isCommandNotFound)('C:\\Windows\\System32\\cmd.exe')).toBe(false); }); });