Skip to content

Commit 069a7d4

Browse files
committed
Updated test
1 parent b714c4a commit 069a7d4

File tree

3 files changed

+53
-42
lines changed

3 files changed

+53
-42
lines changed

test/additionalProperties.test.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -161,26 +161,6 @@ test('additionalProperties - array coerce', (t) => {
161161
t.equal('{"foo":["t","r","u","e"],"ofoo":[],"arrfoo":["1","2"],"objfoo":[]}', stringify(obj))
162162
})
163163

164-
test('additionalProperties - throw on unknown type', (t) => {
165-
t.plan(1)
166-
const stringify = build({
167-
title: 'check array coerce',
168-
type: 'object',
169-
properties: {},
170-
additionalProperties: {
171-
type: 'strangetype'
172-
}
173-
})
174-
175-
const obj = { foo: 'true', ofoo: 0, arrfoo: [1, 2], objfoo: { tyrion: 'lannister' } }
176-
try {
177-
stringify(obj)
178-
t.fail()
179-
} catch (e) {
180-
t.pass()
181-
}
182-
})
183-
184164
test('nested additionalProperties', (t) => {
185165
t.plan(1)
186166
const stringify = build({

test/basic.test.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,56 @@ buildTest({
226226
}, {
227227
readonly: true
228228
})
229+
230+
test('Should throw on invalid schema', t => {
231+
t.plan(1)
232+
try {
233+
build({
234+
type: 'Dinosaur',
235+
properties: {
236+
claws: { type: 'sharp' }
237+
}
238+
})
239+
t.fail('should be an invalid schema')
240+
} catch (err) {
241+
t.ok(err)
242+
}
243+
})
244+
245+
test('additionalProperties - throw on unknown type', (t) => {
246+
t.plan(1)
247+
248+
try {
249+
build({
250+
title: 'check array coerce',
251+
type: 'object',
252+
properties: {},
253+
additionalProperties: {
254+
type: 'strangetype'
255+
}
256+
})
257+
t.fail('should be an invalid schema')
258+
} catch (err) {
259+
t.ok(err)
260+
}
261+
})
262+
263+
test('patternProperties - throw on unknown type', (t) => {
264+
t.plan(1)
265+
266+
try {
267+
build({
268+
title: 'check array coerce',
269+
type: 'object',
270+
properties: {},
271+
patternProperties: {
272+
foo: {
273+
type: 'strangetype'
274+
}
275+
}
276+
})
277+
t.fail('should be an invalid schema')
278+
} catch (err) {
279+
t.ok(err)
280+
}
281+
})

test/patternProperties.test.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -137,25 +137,3 @@ test('patternProperties - array coerce', (t) => {
137137
const obj = { foo: 'true', ofoo: 0, arrfoo: [1, 2], objfoo: { tyrion: 'lannister' } }
138138
t.equal(stringify(obj), '{"foo":["t","r","u","e"],"ofoo":[],"arrfoo":["1","2"],"objfoo":[]}')
139139
})
140-
141-
test('patternProperties - throw on unknown type', (t) => {
142-
t.plan(1)
143-
const stringify = build({
144-
title: 'check array coerce',
145-
type: 'object',
146-
properties: {},
147-
patternProperties: {
148-
foo: {
149-
type: 'strangetype'
150-
}
151-
}
152-
})
153-
154-
const obj = { foo: 'true', ofoo: 0, arrfoo: [1, 2], objfoo: { tyrion: 'lannister' } }
155-
try {
156-
stringify(obj)
157-
t.fail()
158-
} catch (e) {
159-
t.pass()
160-
}
161-
})

0 commit comments

Comments
 (0)