Move fragment type check to normalizer (#2462)

Should result in more informative stack traces.

Fixes #2461
This commit is contained in:
Isiah Meadows 2019-07-07 17:16:56 -04:00 committed by GitHub
parent b2f82e3abc
commit db277217f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 27 deletions

View file

@ -21,4 +21,36 @@ o.spec("normalizeChildren", function() {
o(children[0]).equals(null)
})
o("allows all keys", function() {
var children = Vnode.normalizeChildren([
{key: 1},
{key: 2},
])
o(children).deepEquals([{key: 1}, {key: 2}])
})
o("allows no keys", function() {
var children = Vnode.normalizeChildren([
{data: 1},
{data: 2},
])
o(children).deepEquals([{data: 1}, {data: 2}])
})
o("disallows mixed keys, starting with key", function() {
o(function() {
Vnode.normalizeChildren([
{key: 1},
{data: 2},
])
}).throws(TypeError)
})
o("disallows mixed keys, starting with no key", function() {
o(function() {
Vnode.normalizeChildren([
{data: 1},
{key: 2},
])
}).throws(TypeError)
})
})