confirm.js
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*eslint strict:0*/
casper.test.begin('can confirm dialog', 2, {
received: undefined,
setUp: function(test) {
var self = this;
casper.removeAllFilters('page.confirm');
casper.setFilter('page.confirm', function(message) {
self.received = message;
return true;
});
},
tearDown: function(test) {
casper.removeAllFilters('page.confirm');
},
test: function(test) {
var self = this;
casper.start('tests/site/confirm.html', function() {
test.assert(this.getGlobal('confirmed'), 'confirmation dialog accepted');
}).run(function() {
test.assertEquals(self.received, 'are you sure?', 'confirmation message is ok');
test.done();
});
}
});
casper.test.begin('can cancel dialog', 1, {
received: undefined,
setUp: function(test) {
var self = this;
casper.removeAllFilters('page.confirm');
casper.setFilter('page.confirm', function(message) {
return false;
});
},
tearDown: function(test) {
casper.removeAllFilters('page.confirm');
},
test: function(test) {
var self = this;
casper.start('tests/site/confirm.html', function() {
test.assertNot(this.getGlobal('confirmed'), 'confirmation dialog canceled');
}).run(function() {
test.done();
});
}
});