migrated casper/confirm tests to new test format
Showing
1 changed file
with
21 additions
and
20 deletions
1 | /*global casper*/ | 1 | /*global casper*/ |
2 | /*jshint strict:false*/ | 2 | /*jshint strict:false*/ |
3 | var received; | 3 | casper.test.begin('can confirm dialog', 2, function(test) { |
4 | 4 | var received; | |
5 | casper.setFilter('page.confirm', function(message) { | 5 | casper.removeAllFilters('page.confirm') |
6 | received = message; | 6 | casper.setFilter('page.confirm', function(message) { |
7 | return true; | 7 | received = message; |
8 | }); | 8 | return true; |
9 | 9 | }); | |
10 | casper.start('tests/site/confirm.html', function() { | 10 | casper.start('tests/site/confirm.html', function() { |
11 | this.test.assert(this.getGlobal('confirmed'), 'confirmation dialog accepted'); | 11 | test.assert(this.getGlobal('confirmed'), 'confirmation dialog accepted'); |
12 | }); | ||
13 | casper.run(function() { | ||
14 | test.assertEquals(received, 'are you sure?', 'confirmation message is ok'); | ||
15 | test.done(); | ||
16 | }); | ||
12 | }); | 17 | }); |
13 | 18 | ||
14 | casper.then(function() { | 19 | casper.test.begin('can cancel dialog', 1, function(test) { |
15 | //remove the page.confirm event filter so we can add a new one | ||
16 | casper.removeAllFilters('page.confirm') | 20 | casper.removeAllFilters('page.confirm') |
17 | casper.setFilter('page.confirm', function(message) { | 21 | casper.setFilter('page.confirm', function(message) { |
18 | return false; | 22 | return false; |
19 | }); | 23 | }); |
20 | }); | 24 | casper.start('tests/site/confirm.html', function() { |
21 | 25 | test.assertNot(this.getGlobal('confirmed'), 'confirmation dialog canceled'); | |
22 | casper.thenOpen('/tests/site/confirm.html', function() { | 26 | }); |
23 | this.test.assertNot(this.getGlobal('confirmed'), 'confirmation dialog canceled'); | 27 | casper.run(function() { |
24 | }); | 28 | test.done(); |
25 | 29 | }); | |
26 | casper.run(function() { | ||
27 | this.test.assertEquals(received, 'are you sure?', 'confirmation message is ok'); | ||
28 | this.test.done(3); | ||
29 | }); | 30 | }); | ... | ... |
-
Please register or sign in to post a comment