Skip to content

Commit 5c8973f

Browse files
committed
Baby steps into doing tests with protractor
1 parent c04af3f commit 5c8973f

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

test/protractor/conf.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
exports.config = {
2+
seleniumAddress: 'http://localhost:4444/wd/hub',
3+
specs: ['custom-validation.js']
4+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
describe('Schema Form custom validators', function() {
2+
it('should have a form with content', function() {
3+
browser.get('http://localhost:8080/examples/custom-validators.html');
4+
5+
expect(element(by.css('form')).getInnerHtml()).not.toEqual('');
6+
});
7+
8+
describe('#name', function() {
9+
it('should not complain if it gets a normal name', function() {
10+
browser.get('http://localhost:8080/examples/custom-validators.html');
11+
var input = element.all(by.css('form input')).first();
12+
input.sendKeys('Joe Schmoe');
13+
14+
expect(input.getAttribute('value')).toEqual('Joe Schmoe');
15+
expect(input.evaluate('ngModel.$valid')).toEqual(true);
16+
17+
});
18+
19+
it('should complain if it gets a "Bob" as a name', function() {
20+
browser.get('http://localhost:8080/examples/custom-validators.html');
21+
var input = element.all(by.css('form input')).first();
22+
input.sendKeys('Bob');
23+
24+
expect(input.getAttribute('value')).toEqual('Bob');
25+
expect(input.evaluate('ngModel.$valid')).toEqual(false);
26+
});
27+
});
28+
29+
describe('#email', function() {
30+
it('should not complain if it gets a normal email', function() {
31+
browser.get('http://localhost:8080/examples/custom-validators.html');
32+
var input = element.all(by.css('form input')).get(1);
33+
input.sendKeys('foo@mailinator.com');
34+
35+
expect(input.getAttribute('value')).toEqual('foo@mailinator.com');
36+
expect(input.evaluate('ngModel.$valid')).toEqual(true);
37+
38+
});
39+
40+
it('should complain if it gets a my email', function() {
41+
browser.get('http://localhost:8080/examples/custom-validators.html');
42+
var input = element.all(by.css('form input')).get(1);
43+
input.sendKeys('david.lgj@gmail.com');
44+
45+
expect(input.getAttribute('value')).toEqual('david.lgj@gmail.com');
46+
expect(input.evaluate('ngModel.$valid')).toEqual(false);
47+
});
48+
});
49+
50+
describe('#comment', function() {
51+
it('should not complain if it gets a normal email', function() {
52+
browser.get('http://localhost:8080/examples/custom-validators.html');
53+
var input = element.all(by.css('form input')).get(1);
54+
input.sendKeys('foo@mailinator.com');
55+
56+
expect(input.getAttribute('value')).toEqual('foo@mailinator.com');
57+
expect(input.evaluate('ngModel.$valid')).toEqual(true);
58+
59+
});
60+
61+
it('should complain if it gets a my email', function() {
62+
browser.get('http://localhost:8080/examples/custom-validators.html');
63+
var input = element.all(by.css('form input')).get(1);
64+
input.sendKeys('david.lgj@gmail.com');
65+
66+
expect(input.getAttribute('value')).toEqual('david.lgj@gmail.com');
67+
expect(input.evaluate('ngModel.$valid')).toEqual(false);
68+
});
69+
});
70+
71+
72+
73+
74+
});

0 commit comments

Comments
 (0)