Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9d7ce7a

Browse files
tv4 validation check
1 parent 732ea19 commit 9d7ce7a

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/* global browser, it, describe, element, by */
2+
3+
describe('Schema Form validation messages', function () {
4+
5+
describe('tv4-validators', function () {
6+
var URL = 'angular-schema-form-material/examples/material-example.html#/86fb7505a8ab6a43bc70';
7+
8+
var validationMessageTestBuilder = function (testToDo) {
9+
10+
Object.keys(testToDo.validationCodes).forEach(function (validationCodeIndex) {
11+
it('validation test, expecting class "' + testToDo.validationCodes[validationCodeIndex] + ' when input is ' + testToDo.value, function () {
12+
13+
browser.get(URL);
14+
var input = element.all(by.css('form[name=ngform] input')).get(testToDo.field);
15+
input.sendKeys(testToDo.value);
16+
17+
expect(input.evaluate('ngModel.$valid')).toEqual(testToDo.valid);
18+
expect(input.getAttribute('class')).toMatch(testToDo.validationCodes[validationCodeIndex])
19+
20+
21+
});
22+
23+
});
24+
25+
};
26+
27+
28+
var testsToDo = [
29+
{
30+
field: 0, //0 string, 1 integer
31+
value: "s",
32+
validationCodes: ['ng-invalid-tv4-200'],
33+
valid: false
34+
},
35+
{
36+
field: 0,
37+
value: 'tooo long string',
38+
validationCodes: ['ng-invalid-tv4-201'],
39+
valid: false
40+
},
41+
{
42+
field: 0,
43+
value: 'foo 66',
44+
validationCodes: ['ng-invalid-tv4-202'],
45+
valid: false
46+
},
47+
{
48+
field: 0,
49+
value: 'foobar',
50+
validationCodes: ['ng-valid-tv4-200'],
51+
valid: true
52+
},
53+
{
54+
field: 1,
55+
value: '3',
56+
validationCodes: ['ng-invalid-tv4-101'],
57+
valid: false
58+
},
59+
{
60+
field: 1,
61+
value: '66',
62+
validationCodes: ['ng-invalid-tv4-103'],
63+
valid: false
64+
},
65+
{
66+
field: 1,
67+
value: '11',
68+
validationCodes: ['ng-invalid-tv4-100'],
69+
valid: false
70+
},
71+
{
72+
field: 1,
73+
value: 'aaa',
74+
validationCodes: ['ng-invalid-tv4-302'],
75+
valid: false
76+
}
77+
];
78+
79+
80+
Object.keys(testsToDo).forEach(function (testToDoIndex) {
81+
validationMessageTestBuilder(testsToDo[testToDoIndex]);
82+
});
83+
84+
85+
});
86+
});

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /