Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions test/string.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ test('serialize short string', (t) => {
t.assert.equal(JSON.parse(output), input)
})

test('serialize medium string', (t) => {
t.plan(2)

const schema = {
type: 'string'
}

const input = new Array(2e4).fill('\x00').join('')
const stringify = build(schema)
const output = stringify(input)

t.assert.equal(output, `"${new Array(150).fill('\\u0000').join('')}"`)
t.assert.equal(JSON.parse(output), input)
})

test('serialize long string', (t) => {
t.plan(2)

Expand Down
Loading