MCPcopy Create free account
hub / github.com/ded/reqwest / testInput

Function testInput

tests/tests.js:962–997  ·  view source on GitHub ↗
(input, name, value, str)

Source from the content-addressed store, hash-verified

960 }
961
962 function testInput(input, name, value, str) {
963 var sa = ajax.serialize(input, { type: 'array' })
964 , sh = ajax.serialize(input, { type: 'map' })
965 , av, i
966
967 if (value != null) {
968 av = isArray(value) ? value : [ value ]
969
970 ok(
971 sa.length == av.length
972 , 'serialize(' + str + ', {type:\'array\'}) returns array '
973 + '[{name,value}]'
974 )
975
976 for (i = 0; i < av.length; i++) {
977 ok(
978 name == sa[i].name
979 , 'serialize(' + str + ', {type:\'array\'})[' + i + '].name'
980 )
981 ok(
982 av[i] == sa[i].value
983 , 'serialize(' + str + ', {type:\'array\'})[' + i + '].value'
984 )
985 }
986
987 ok(sameValue(sh[name], value), 'serialize(' + str + ', {type:\'map\'})')
988 } else {
989 // the cases where an element shouldn't show up at all, checkbox not
990 // checked for example
991 ok(sa.length === 0, 'serialize(' + str + ', {type:\'array\'}) is []')
992 ok(
993 v.keys(sh).length === 0
994 , 'serialize(' + str + ', {type:\'map\'}) is {}'
995 )
996 }
997 }
998
999 function testFormSerialize(method, type) {
1000 var expected =

Callers

nothing calls this directly

Calls 2

isArrayFunction · 0.85
sameValueFunction · 0.85

Tested by

no test coverage detected