Skip to content

Commit 0156887

Browse files
committed
Updated test
1 parent f486879 commit 0156887

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,14 @@ test('parse', t => {
185185
t.end()
186186
})
187187

188+
t.test('sanitizes object string (no prototype key)', t => {
189+
t.deepEqual(
190+
j.parse('{"a": 5, "b": 6,"constructor":{"bar":"baz"} }', { constructorAction: 'remove' }),
191+
{ a: 5, b: 6, constructor: { bar: 'baz' } }
192+
)
193+
t.end()
194+
})
195+
188196
t.test('sanitizes nested object string', t => {
189197
t.deepEqual(
190198
j.parse('{ "a": 5, "b": 6, "constructor":{"prototype":{"bar":"baz"}}, "c": { "d": 0, "e": "text", "constructor":{"prototype":{"bar":"baz"}}, "f": { "g": 2 } } }', { constructorAction: 'remove' }),
@@ -217,6 +225,11 @@ test('parse', t => {
217225
t.end()
218226
})
219227

228+
t.test('Should not throw if the constructor key hasn\'t a child named prototype', t => {
229+
t.doesNotThrow(() => j.parse('{ "a": 5, "b": 6, "constructor":{"bar":"baz"} }', null, null), SyntaxError)
230+
t.end()
231+
})
232+
220233
t.test('errors on proto property (null, null)', t => {
221234
t.throws(() => j.parse('{ "a": 5, "b": 6, "constructor":{"prototype":{"bar":"baz"}} }', null, null), SyntaxError)
222235
t.end()

0 commit comments

Comments
 (0)