Skip to content

Commit 43f5ee9

Browse files
authored
chore: 582 - improving test coverage (#608)
1 parent 2c568d7 commit 43f5ee9

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

index.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -571,12 +571,8 @@ function buildArray (context, location) {
571571
`
572572
}
573573

574-
if (largeArrayMechanism !== 'default') {
575-
if (largeArrayMechanism === 'json-stringify') {
576-
functionCode += `if (arrayLength && arrayLength >= ${largeArraySize}) return JSON.stringify(obj)\n`
577-
} else {
578-
throw new Error(`Unsupported large array mechanism ${largeArrayMechanism}`)
579-
}
574+
if (largeArrayMechanism === 'json-stringify') {
575+
functionCode += `if (arrayLength && arrayLength >= ${largeArraySize}) return JSON.stringify(obj)\n`
580576
}
581577

582578
functionCode += `
@@ -663,8 +659,6 @@ function buildArrayTypeCondition (type, accessor) {
663659
return buildArrayTypeCondition(subType, accessor)
664660
})
665661
condition = `(${conditions.join(' || ')})`
666-
} else {
667-
throw new Error(`${type} unsupported`)
668662
}
669663
}
670664
return condition

test/integer.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ test('render a float as an integer', (t) => {
3535
}
3636
})
3737

38+
test('throws on NaN', (t) => {
39+
t.plan(1)
40+
41+
const schema = {
42+
title: 'integer',
43+
type: 'integer'
44+
}
45+
46+
const stringify = build(schema)
47+
t.throws(() => stringify(NaN), new Error('The value "NaN" cannot be converted to an integer.'))
48+
})
49+
3850
test('render a float as an integer', (t) => {
3951
const cases = [
4052
{ input: Math.PI, output: '3' },

0 commit comments

Comments
 (0)