You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
test('should throw a TypeError with the path to the key of the invalid value /1',(t)=>{
157
-
t.plan(1)
157
+
t.plan(3)
158
158
159
159
// any on Foo codepath.
160
160
constschema={
@@ -186,16 +186,21 @@ test('should throw a TypeError with the path to the key of the invalid value /1'
186
186
187
187
conststringify=build(schema)
188
188
189
-
t.throws(()=>stringify({kind: 'Baz',value: 1}),Object.assign(newTypeError('The value of \'#\' does not match schema definition.'),{
190
-
validationErrors: [
191
-
{message: 'must be equal to one of the allowed values',schemaPath: '#/properties/kind/enum',instancePath: '/kind'},
192
-
{message: 'must be equal to one of the allowed values',schemaPath: '#/properties/kind/enum',instancePath: '/kind'}
193
-
]
194
-
}))
189
+
try{
190
+
stringify({kind: 'Baz',value: 1})
191
+
t.fail('should throw')
192
+
}catch(err){
193
+
t.equal(err.message,'The value of \'#\' does not match schema definition.')
194
+
t.same(err.validationErrors,[
195
+
{message: 'must be equal to one of the allowed values',schemaPath: '#/properties/kind/enum',instancePath: '/kind',keyword: 'enum',params: {allowedValues: ['Foo']}},
196
+
{message: 'must be equal to one of the allowed values',schemaPath: '#/properties/kind/enum',instancePath: '/kind',keyword: 'enum',params: {allowedValues: ['Bar']}}
197
+
])
198
+
t.ok(errinstanceofTypeError)
199
+
}
195
200
})
196
201
197
202
test('should throw a TypeError with the path to the key of the invalid value /2',(t)=>{
198
-
t.plan(1)
203
+
t.plan(3)
199
204
200
205
// any on Foo codepath.
201
206
constschema={
@@ -232,10 +237,15 @@ test('should throw a TypeError with the path to the key of the invalid value /2'
232
237
233
238
conststringify=build(schema)
234
239
235
-
t.throws(()=>stringify({data: {kind: 'Baz',value: 1}}),Object.assign(newTypeError('The value of \'#/properties/data\' does not match schema definition.'),{
236
-
validationErrors: [
237
-
{message: 'must be equal to one of the allowed values',schemaPath: '#/properties/kind/enum',instancePath: '/kind'},
238
-
{message: 'must be equal to one of the allowed values',schemaPath: '#/properties/kind/enum',instancePath: '/kind'}
239
-
]
240
-
}))
240
+
try{
241
+
stringify({data: {kind: 'Baz',value: 1}})
242
+
t.fail('should throw')
243
+
}catch(err){
244
+
t.equal(err.message,'The value of \'#/properties/data\' does not match schema definition.')
245
+
t.same(err.validationErrors,[
246
+
{message: 'must be equal to one of the allowed values',schemaPath: '#/properties/kind/enum',instancePath: '/kind',keyword: 'enum',params: {allowedValues: ['Foo']}},
247
+
{message: 'must be equal to one of the allowed values',schemaPath: '#/properties/kind/enum',instancePath: '/kind',keyword: 'enum',params: {allowedValues: ['Bar']}}
0 commit comments