Skip to content

Commit 6ec6365

Browse files
authored
add test for largeArrayMechanism (#543)
1 parent 0a4f626 commit 6ec6365

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ function build (schema, options) {
110110
if (validLargeArrayMechanisms.includes(options.largeArrayMechanism)) {
111111
largeArrayMechanism = options.largeArrayMechanism
112112
} else {
113-
throw new Error(`Unsupported large array mechanism ${options.rounding}`)
113+
throw new Error(`Unsupported large array mechanism ${options.largeArrayMechanism}`)
114114
}
115115
}
116116

test/array.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,24 @@ const test = require('tap').test
44
const validator = require('is-my-json-valid')
55
const build = require('..')
66

7+
test('error on invalid largeArrayMechanism', (t) => {
8+
t.plan(1)
9+
10+
t.throws(() => build({
11+
title: 'large array of null values with default mechanism',
12+
type: 'object',
13+
properties: {
14+
ids: {
15+
type: 'array',
16+
items: { type: 'null' }
17+
}
18+
}
19+
}, {
20+
largeArraySize: 2e4,
21+
largeArrayMechanism: 'invalid'
22+
}), Error('Unsupported large array mechanism invalid'))
23+
})
24+
725
function buildTest (schema, toStringify, options) {
826
test(`render a ${schema.title} as JSON`, (t) => {
927
t.plan(3)

0 commit comments

Comments
 (0)