|
1 |
| -casper.test.begin('Validation', 4, function (test) { |
| 1 | +casper.test.begin('Validation', 9, function (test) { |
2 | 2 |
|
3 | 3 | casper
|
4 | 4 | .start('./fixtures/validation.html')
|
5 | 5 | .then(function () {
|
6 | 6 | test.assertElementCount('.valid', 0)
|
7 |
| - this.sendKeys('input', '@hello.com') |
| 7 | + this.sendKeys('input[name="name"]', 'haha') |
8 | 8 | })
|
9 | 9 | .then(function () {
|
10 | 10 | test.assertElementCount('.valid', 1)
|
| 11 | + this.sendKeys('input[name="email"]', 'hello') |
11 | 12 | })
|
| 13 | + .then(function () { |
| 14 | + // email should be invalid |
| 15 | + test.assertElementCount('.valid', 1) |
| 16 | + this.sendKeys('input[name="email"]', '[email protected]', { reset: true }) |
| 17 | + }) |
| 18 | + .then(function () { |
| 19 | + // email should be valid now |
| 20 | + test.assertField('email', '[email protected]') |
| 21 | + test.assertElementCount('.valid', 2) |
| 22 | + }) |
| 23 | + // test edit/insertion when there are filters |
12 | 24 | .thenEvaluate(function () {
|
13 |
| - document.querySelector('input').setSelectionRange(4,4) |
| 25 | + document.querySelector('input[name="email"]').setSelectionRange(2,2) |
14 | 26 | })
|
15 | 27 | .then(function () {
|
16 |
| - this.sendKeys('input', 'hoho') |
| 28 | + this.sendKeys('input[name="email"]', 'll') |
17 | 29 | })
|
18 | 30 | .then(function () {
|
19 |
| - test.assertElementCount('.valid', 1) |
20 |
| - test.assertField('email', '[email protected]') |
| 31 | + test.assertElementCount('.valid', 2) |
| 32 | + test.assertField('email', '[email protected]') |
| 33 | + }) |
| 34 | + .thenClick('#go', function () { |
| 35 | + test.assertElementCount('.user', 1) |
| 36 | + test.assertSelectorHasText('.user', 'haha [email protected]') |
21 | 37 | })
|
22 | 38 | .run(function () {
|
23 | 39 | test.done()
|
|
0 commit comments