Skip to content

Commit f9c82eb

Browse files
author
赵长伟
committed
Add unit test for json post
1 parent 092fa60 commit f9c82eb

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/test.js

+20
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,26 @@ describe('form', function() {
6565
}
6666
});
6767

68+
it('formToArray: json object', function() {
69+
var a = $('#form1').formToArray();
70+
var o = $.fn.formArrayToJsonData(a);
71+
// console.log(JSON.stringify(o,0,4));
72+
assert.strictEqual(o.constructor, Object, 'type check');
73+
assert.deepEqual(o, {
74+
"Hidden": "hiddenValue",
75+
"Name": "MyName1",
76+
"Password": "",
77+
"Multiple": "six",
78+
"Single": "one",
79+
"Single2": "A",
80+
"Check": "2",
81+
"Radio": "2",
82+
"action": "1",
83+
"method": "2",
84+
"Text": "This is Form1"
85+
});
86+
});
87+
6888
it('formToArray: text promotion for missing value attributes', function() {
6989
var expected = [
7090
{ name: 'A', value: ''},

0 commit comments

Comments
 (0)