bypass.js
2.9 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*global casper*/
/*jshint strict:false*/
casper.test.begin('Casper.bypass() can bypass a step', 1, function(test) {
casper.start();
casper.then(function(){
test.fail("This test should not be executed.");
});
casper.bypass(1).run(function() {
test.pass("Step has been bypassed");
test.done();
});
});
casper.test.begin('Casper.bypass() can bypass multiple steps', 1, function(test) {
casper.start();
casper.then(function() {
test.pass("This test should be executed.");
});
casper.then(function() {
this.bypass(2);
});
casper.then(function() {
test.fail("This test should not be executed.");
});
casper.then(function() {
test.fail("Nor this one.");
});
casper.run(function() {
test.done();
});
});
casper.test.begin('Casper.thenBypass()', 1, function(test) {
casper.
thenBypass(1).
then(function() {
test.fail("This test should be bypassed.");
}).
then(function() {
test.pass("This test should be executed.");
});
casper.run(function() {
test.done();
});
});
casper.test.begin('Casper.thenBypassIf()', 3, function(test) {
casper.
thenBypassIf(true, 1, "Bypass if with function").
then(function() {
test.fail("This test should be bypassed.");
}).
then(function() {
test.pass("This test should be executed.");
}).
thenBypassIf(function() {
return true;
}, 1, "Bypass if with function").
then(function() {
test.fail("This test should be bypassed.");
}).
then(function() {
test.pass("This test should be executed.");
}).
thenBypassIf(function() {
return false;
}, 1, "Do not bypass if with function").
then(function() {
test.pass("This test should be executed.");
});
casper.run(function() {
test.done();
});
});
casper.test.begin('Casper.thenBypassUnless()', 3, function(test) {
casper.
thenBypassUnless(false, 1, "Bypass unless with function").
then(function() {
test.fail("This test should be bypassed.");
}).
then(function() {
test.pass("This test should be executed.");
}).
thenBypassUnless(function() {
return false;
}, 1, "Bypass unless with function").
then(function() {
test.fail("This test should be bypassed.");
}).
then(function() {
test.pass("This test should be executed.");
}).
thenBypassUnless(function() {
return true;
}, 1, "Do not bypass unless with function").
then(function() {
test.pass("This test should be executed.");
});
casper.run(function() {
test.done();
});
});