Skip to content

Commit d9b2ee5

Browse files
committed
Added unit test cases for autocomplete
1 parent 7999ff2 commit d9b2ee5

File tree

4 files changed

+307
-125
lines changed

4 files changed

+307
-125
lines changed

test/checks/forms/autocomplete-valid.js

Lines changed: 186 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,200 @@ describe('autocomplete-valid', function() {
1111
checkContext.reset();
1212
});
1313

14-
it('returns true if autocomplete is valid', function() {
15-
var params = checkSetup('<input autocomplete="on" id="target" />');
14+
// original axe-core's check test
15+
16+
// it('returns true if autocomplete is valid', function() {
17+
// var params = checkSetup('<input autocomplete="on" id="target" />');
18+
// assert.isTrue(evaluate.apply(checkContext, params));
19+
// });
20+
21+
// it('returns false if autocomplete is not valid', function() {
22+
// var params = checkSetup('<input autocomplete="foo" id="target" />');
23+
// assert.isFalse(evaluate.apply(checkContext, params));
24+
// });
25+
26+
// it('uses options to change what is valid autocomplete', function() {
27+
// var options = { stateTerms: ['foo'] };
28+
// var params = checkSetup(
29+
// '<input autocomplete="foo" id="target" />',
30+
// options
31+
// );
32+
// assert.isTrue(evaluate.apply(checkContext, params));
33+
// });
34+
35+
it("evaluate() passes a document if form element has autocomplete set off and child elements don't have autocomplete", function() {
36+
console.log('Our functions are running fine');
37+
var params = checkSetup(
38+
'<html> <form autocomplete="off" onsubmit="javascript(0)"> <input type="text" id="target"/> <button>Save</button> </form> </html>'
39+
);
40+
assert.isTrue(evaluate.apply(checkContext, params));
41+
});
42+
43+
it('evaluate() passes a document if form element has autocomplete set off and child elements have autocomplete as off', function() {
44+
var params = checkSetup(
45+
'<html> <form autocomplete="off" onsubmit="javascript(0)"> <input autocomplete="off" type="text" id="target"/> <button>Save</button> </form> </html>'
46+
);
47+
assert.isTrue(evaluate.apply(checkContext, params));
48+
});
49+
50+
it('evaluate() passes a document if form element has autocomplete set off and child elements have standard autcomplete value', function() {
51+
var params = checkSetup(
52+
'<html> <form autocomplete="off" onsubmit="javascript(0)"> <input autocomplete="username" type="text" id="target"/> <button>Save</button> </form> </html>'
53+
);
54+
assert.isTrue(evaluate.apply(checkContext, params));
55+
});
56+
57+
it('evaluate() passes a document if form element has autocomplete set off, child elements have on autocomplete value and name or id has standard autocomplete value', function() {
58+
var params = checkSetup(
59+
'<html> <form autocomplete="off" onsubmit="javascript(0)"> <input autocomplete="on" name="name" type="text" id="target"/> <button>Save</button> </form> </html>'
60+
);
61+
assert.isTrue(evaluate.apply(checkContext, params));
62+
});
63+
64+
it('evaluate() fails a document if form element has autocomplete set off and child elements have on autocomplete value and name or id has non-standard autocomplete value', function() {
65+
var params = checkSetup(
66+
'<html> <form autocomplete="off" onsubmit="javascript(0)"> <input autocomplete="on" name="xname" type="text" id="target"/> <button>Save</button> </form> </html>'
67+
);
68+
assert.isFalse(evaluate.apply(checkContext, params));
69+
});
70+
71+
it('evaluate() passes a document if form element has autocomplete set off, child elements have non-standard autocomplete value and name or id has standard autocomplete value', function() {
72+
var params = checkSetup(
73+
'<html> <form autocomplete="off" onsubmit="javascript(0)"> <input autocomplete="xname" name="name" type="text" id="target"/> <button>Save</button> </form> </html>'
74+
);
75+
assert.isTrue(evaluate.apply(checkContext, params));
76+
});
77+
78+
it('evaluate() fails a document if form element has autocomplete set off, child elements have non-standard autocomplete value and name or id has non-standard autocomplete value', function() {
79+
var params = checkSetup(
80+
'<html> <form autocomplete="off" onsubmit="javascript(0)"> <input autocomplete="xname" name="xname" type="text" id="target"/> <button>Save</button> </form> </html>'
81+
);
82+
assert.isFalse(evaluate.apply(checkContext, params));
83+
});
84+
85+
it('evaluate() passes a document if form element has autocomplete set on and child elements have autocomplete set to off', function() {
86+
var params = checkSetup(
87+
'<html> <form autocomplete="on" onsubmit="javascript(0)"> <input autocomplete="off" type="text" id="target"/> <button>Save</button> </form> </html>'
88+
);
89+
assert.isTrue(evaluate.apply(checkContext, params));
90+
});
91+
92+
it("evaluate() passes a document if form element doesn't have autocomplete set and child elements have autocomplete set to off", function() {
93+
var params = checkSetup(
94+
'<html> <form onsubmit="javascript(0)"> <input autocomplete="off" type="text" id="target"/> <button>Save</button> </form> </html>'
95+
);
96+
assert.isTrue(evaluate.apply(checkContext, params));
97+
});
98+
99+
it('evaluate() passes a document if form element has autocomplete set on and child elements have autocomplete set to standard irrespective of name and id', function() {
100+
var params = checkSetup(
101+
'<html> <form autocomplete="on" onsubmit="javascript(0)"> <input autocomplete="name" type="text" name="xname" id="target"/> <button>Save</button> </form> </html>'
102+
);
103+
assert.isTrue(evaluate.apply(checkContext, params));
104+
});
105+
106+
it("evaluate() passes a document if form element doesn't have autocomplete set and child elements have autocomplete set to standard irrespective of name and id", function() {
107+
var params = checkSetup(
108+
'<html> <form onsubmit="javascript(0)"> <input autocomplete="name" type="text" name="xname" id="target"/> <button>Save</button> </form> </html>'
109+
);
110+
assert.isTrue(evaluate.apply(checkContext, params));
111+
});
112+
113+
it('evaluate() passes a document if form element has autocomplete set on and child elements have autocomplete set on and name/id have a standard autocomplete value', function() {
114+
var params = checkSetup(
115+
'<html> <form autocomplete="on" onsubmit="javascript(0)"> <input autocomplete="on" type="text" name="name" id="target"/> <button>Save</button> </form> </html>'
116+
);
117+
assert.isTrue(evaluate.apply(checkContext, params));
118+
});
119+
120+
it("evaluate() passes a document if form element doesn't have autocomplete set and child elements have autocomplete set on and name/id have a standard autocomplete value", function() {
121+
var params = checkSetup(
122+
'<html> <form autocomplete="on" onsubmit="javascript(0)"> <input autocomplete="on" type="text" name="name" id="target"/> <button>Save</button> </form> </html>'
123+
);
16124
assert.isTrue(evaluate.apply(checkContext, params));
17125
});
18126

19-
it('returns false if autocomplete is not valid', function() {
20-
var params = checkSetup('<input autocomplete="foo" id="target" />');
127+
it('evaluate() fails a document if form element has autocomplete set on and child elements have autocomplete set on and name/id have a non-standard autocomplete value', function() {
128+
var params = checkSetup(
129+
'<html> <form autocomplete="on" onsubmit="javascript(0)"> <input autocomplete="on" type="text" name="xname" id="target"/> <button>Save</button> </form> </html>'
130+
);
21131
assert.isFalse(evaluate.apply(checkContext, params));
22132
});
23133

24-
it('uses options to change what is valid autocomplete', function() {
25-
var options = { stateTerms: ['foo'] };
134+
it("evaluate() fails a document if form element doesn't have autcomplete set and child elements have autocomplete set on and name/id have a non-standard autocomplete value", function() {
135+
var params = checkSetup(
136+
'<html> <form onsubmit="javascript(0)"> <input autocomplete="on" type="text" name="xname" id="target"/> <button>Save</button> </form> </html>'
137+
);
138+
assert.isFalse(evaluate.apply(checkContext, params));
139+
});
140+
141+
it("evaluate() passes a document if form element has autocomplete set on and child elements don't have autocomplete set and name/id have a standard autocomplete value", function() {
142+
var params = checkSetup(
143+
'<html> <form autocomplete="on" onsubmit="javascript(0)"> <input type="text" name="name" id="target"/> <button>Save</button> </form> </html>'
144+
);
145+
assert.isTrue(evaluate.apply(checkContext, params));
146+
});
147+
148+
it("evaluate() passes a document if form element doesn't have autocomplete set and child elements don't have autocomplete set and name/id have a standard autocomplete value", function() {
26149
var params = checkSetup(
27-
'<input autocomplete="foo" id="target" />',
28-
options
150+
'<html> <form onsubmit="javascript(0)"> <input type="text" name="name" id="target"/> <button>Save</button> </form> </html>'
29151
);
30152
assert.isTrue(evaluate.apply(checkContext, params));
31153
});
154+
155+
it("evaluate() fails a document if form element has autocomplete set on and child elements don't have autocomplete set and name/id have a non-standard autocomplete value", function() {
156+
var params = checkSetup(
157+
'<html> <form autocomplete="on" onsubmit="javascript(0)"> <input type="text" name="xname" id="target"/> <button>Save</button> </form> </html>'
158+
);
159+
assert.isFalse(evaluate.apply(checkContext, params));
160+
});
161+
162+
it("evaluate() fails a document if form element doesn't have autocomplete set and child elements don't have autocomplete set and name/id have a non-standard autocomplete value", function() {
163+
var params = checkSetup(
164+
'<html> <form onsubmit="javascript(0)"> <input type="text" name="xname" id="target"/> <button>Save</button> </form> </html>'
165+
);
166+
assert.isFalse(evaluate.apply(checkContext, params));
167+
});
168+
169+
it('evaluate() passes a document if element is independent and have autocomplete set to off', function() {
170+
var params = checkSetup(
171+
'<html> <input autocomplete="off" type="text" id="target"/> <button>Save</button> </html>'
172+
);
173+
assert.isTrue(evaluate.apply(checkContext, params));
174+
});
175+
176+
it('evaluate() passes a document if element is independent and have autocomplete set to standard irrespective of name and id', function() {
177+
var params = checkSetup(
178+
'<html> <input autocomplete="name" type="text" name="xname" id="target"/> <button>Save</button> </html>'
179+
);
180+
assert.isTrue(evaluate.apply(checkContext, params));
181+
});
182+
183+
it('evaluate() passes a document if element is independent and have autocomplete set on and name/id have a standard autocomplete value', function() {
184+
var params = checkSetup(
185+
'<html> <input autocomplete="on" type="text" name="name" id="target"/> <button>Save</button> </html>'
186+
);
187+
assert.isTrue(evaluate.apply(checkContext, params));
188+
});
189+
190+
it('evaluate() fails a document if element is independent and have autocomplete set on and name/id have a non-standard autocomplete value', function() {
191+
var params = checkSetup(
192+
'<html> <input autocomplete="on" type="text" name="xname" id="target"/> <button>Save</button> </html>'
193+
);
194+
assert.isFalse(evaluate.apply(checkContext, params));
195+
});
196+
197+
it("evaluate()passes a document if element is independent and don't have autocomplete set and name/id have a standard autocomplete value", function() {
198+
var params = checkSetup(
199+
'<html> <input type="text" name="name" id="target"/> <button>Save</button> </html>'
200+
);
201+
assert.isTrue(evaluate.apply(checkContext, params));
202+
});
203+
204+
it("evaluate() fails a document if element is independent and don't have autocomplete set and name/id have a non-standard autocomplete value", function() {
205+
var params = checkSetup(
206+
'<html> <input type="text" name="xname" id="target"/> <button>Save</button> </html>'
207+
);
208+
assert.isFalse(evaluate.apply(checkContext, params));
209+
});
32210
});

0 commit comments

Comments
 (0)