mirror of
https://github.com/supabase/supabase.git
synced 2026-06-22 04:52:48 +08:00
* Fix tests in tests/unit, tests/components and files under tests, looking into tests/pages * Fix tests under pages/projects root * Fix * Comment out broken tests that im stuck with * Fix api-report.test * Fix storage-report-test * chore: fix some tests * chore: remove logging * Fix LogsPreviewer.test.js * Fix most of logs-query-test * Skip broken tests instead of false positiving them --------- Co-authored-by: TzeYiing <[email protected]>
37 lines
1.4 KiB
JavaScript
37 lines
1.4 KiB
JavaScript
import { removeJSONTrailingComma } from 'lib/helpers.ts'
|
|
|
|
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)
|
|
})
|
|
})
|