ruvector/studio/tests/components/Editor/RemoveJSONTrailingComma.utils.test.ts
rUv 814f595995 feat(studio): Add complete RuVector Studio application
Major additions:
- Complete Next.js studio application with 1600+ components
- Docker support (Dockerfile.combined, docker-compose.yml)
- GCP deployment documentation and benchmarks
- SQL benchmark scripts for performance testing
- Sentry integration for monitoring
- Comprehensive test suite and mocks

Studio features:
- Dashboard and admin interfaces
- Data visualization components
- Authentication and user management
- API integration with RuVector backend
- Static data and public assets

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-06 23:04:48 +00:00

37 lines
1.4 KiB
TypeScript

import { removeJSONTrailingComma } from 'lib/helpers'
import { describe, it, expect } from 'vitest'
describe('removeJSONTrailingComma', () => {
it('should handle an empty object', () => {
const jsonString = '{}'
expect(removeJSONTrailingComma(jsonString)).toEqual(jsonString)
})
it('should handle an empty array', () => {
const jsonString = '[]'
expect(removeJSONTrailingComma(jsonString)).toEqual(jsonString)
})
it('should handle a JSON string without a trailing comma', () => {
const jsonString = '{"name": "John", "age": 25}'
expect(removeJSONTrailingComma(jsonString)).toEqual(jsonString)
})
it('should remove a trailing comma for JSON object', () => {
const jsonString = '{"name": "John", "age": 25,}'
const expectedOutput = '{"name": "John", "age": 25}'
expect(removeJSONTrailingComma(jsonString)).toEqual(expectedOutput)
})
it('should remove a trailing commas in an array of objects', () => {
const jsonString = '[{"fruit1": "apple","fruit2": "banana",}]'
const expectedOutput = '[{"fruit1": "apple","fruit2": "banana"}]'
expect(removeJSONTrailingComma(jsonString)).toEqual(expectedOutput)
})
it('should remove all trailing commas in an array of objects', () => {
const jsonString = '[{"fruit1": "apple","fruit2": "banana",},]'
const expectedOutput = '[{"fruit1": "apple","fruit2": "banana"}]'
expect(removeJSONTrailingComma(jsonString)).toEqual(expectedOutput)
})
})