Import AITURK IDE 1.0.0-beta.1 from Hermes 63279301; preserve MIT license
This commit is contained in:
commit
03634b1ca3
11340 files changed
+3442369
No files matched your search
@@ -0,0 +1,26 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { tryFormatJson } from './json-format'
|
||||
|
||||
describe('tryFormatJson', () => {
|
||||
it('pretty-prints compact JSON', () => {
|
||||
expect(tryFormatJson('{"a":1,"b":[2,3]}')).toEqual({
|
||||
ok: true,
|
||||
text: '{\n "a": 1,\n "b": [\n 2,\n 3\n ]\n}'
|
||||
})
|
||||
})
|
||||
|
||||
it('leaves empty input unchanged', () => {
|
||||
expect(tryFormatJson(' ')).toEqual({ ok: true, text: ' ' })
|
||||
})
|
||||
|
||||
it('reports parse errors', () => {
|
||||
const result = tryFormatJson('{bad')
|
||||
|
||||
expect(result.ok).toBe(false)
|
||||
|
||||
if (!result.ok) {
|
||||
expect(result.error.length).toBeGreaterThan(0)
|
||||
}
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user