-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtests.html
More file actions
167 lines (124 loc) · 3.4 KB
/
tests.html
File metadata and controls
167 lines (124 loc) · 3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.6.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/qunit/git/qunit.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/qunit/git/qunit.css" type="text/css" media="screen" />
<script src="jquery.inputs.js"></script>
<script>
jQuery(function($){
test('get', function(){
var actual = $('#test-form').inputs('get');
var expected = {
test: {
text: 'textval',
textarea: 'textareaval',
select: {
options: ['a', 'b']
},
radio: '2',
checkbox: ['1', '3']
}
};
deepEqual( actual, expected, 'form get returns expected json' );
});
test('setget1', function(){
$('#test-form').inputs('set', {
test: {
text: 'new',
select: {
options: 'b'
},
radio: '1',
checkbox: '2'
}
});
var actual = $('#test-form').inputs('get');
var expected = {
test: {
text: 'new',
textarea: '',
select: {
options: 'b'
},
radio: '1',
checkbox: '2'
}
};
deepEqual( actual, expected, 'form set/get returns expected json' );
});
test('setget2', function(){
$('#test-form').inputs('set', {
test: {
text: 'new2',
select: {
options: ['a']
},
radio: 2,
checkbox: [1, 2]
}
});
var actual = $('#test-form').inputs('get');
var expected = {
test: {
text: 'new2',
textarea: '',
select: {
options: 'a'
},
radio: '2',
checkbox: ['1', '2']
}
};
deepEqual( actual, expected, 'form set/get returns expected json' );
});
test('keygen get', function(){
var actual = $('#test-keygen').inputs('get');
var expected = {
values: {0: 'a', 1: 'b', 2: 'c'}
};
deepEqual( actual, expected, 'keygen returns expected json' );
});
test('keygen set/get', function(){
$('#test-keygen').inputs('set', {
values: {0: 1, 1: 2, 2: 3}
});
var actual = $('#test-keygen').inputs('get');
var expected = {
values: {0: '1', 1: '2', 2: '3'}
};
deepEqual( actual, expected, 'keygen set/get returns expected json' );
});
});
</script>
</head>
<body>
<h1 id="qunit-header">jquery-inputs plugin tests</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">
<form id="test-form">
<input type="text" name="test_text" value="textval" />
<textarea name="test_textarea">textareaval</textarea>
<select name="test[select].options" multiple="multiple">
<option value="a" selected="selected">Option A</option>
<option value="b" selected="selected">Option B</option>
</select>
<button type="button">Test</button>
<label><input type="radio" name="test_radio" value="1" />1</label>
<label><input type="radio" name="test[radio]" value="2" checked="checked" />2</label>
<label><input type="radio" name="test.radio" value="3" />3</label>
<label><input type="checkbox" name="test[checkbox]" value="1" checked="checked" />1</label>
<label><input type="checkbox" name="test_checkbox" value="2" />2</label>
<label><input type="checkbox" name="test.checkbox" value="3" checked="checked" />3</label>
</form>
<form id="test-keygen">
<input type="text" name="values[]" value="a" />
<input type="text" name="values[]" value="b" />
<input type="text" name="values[]" value="c" />
</form>
</div>
</body>
</html>