-
Notifications
You must be signed in to change notification settings - Fork 1
/
mochachino.js
67 lines (52 loc) · 1.45 KB
/
mochachino.js
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
/*!
* Phantom Mochachino
* http://doublenegative.com/phantom-mochachino
*
* Copyright 2014 Thomas Clowes <thomas@doublenegative.com>
* Released under the MIT license
*/
function Mochachino() {
this.executedItems = [];
this.isChanging = false;
this.pageChanges = [];
this.injectedArgs = [];
}
Mochachino.prototype.shouldWeContinue = function(testTitle) {
if (this.executedItems.indexOf(testTitle) > -1 || this.isChanging) {
return false;
}
return true;
}
Mochachino.prototype.logExecution = function(testTitle) {
this.executedItems.push(testTitle);
}
Mochachino.prototype.exit = function() {
window.callPhantom({ exit: true });
}
Mochachino.prototype.logPageChange = function(testTitle) {
this.pageChanges.push(testTitle);
}
Mochachino.prototype.willChangePages = function() {
this.isChanging = true;
}
Mochachino.prototype.pageWillChange = function() {
window.callPhantom({ executedItems: this.executedItems });
}
Mochachino.prototype.testDifferentPaths = function() {
window.callPhantom({ executedItems: this.executedItems, differentPath: true});
}
var mochachino = new Mochachino();
mochachino.setup = function(executedItems) {
var length = executedItems.length;
this.executedItems = executedItems;
}
mochachino.injectArgs = function(args) {
this.injectedArgs = args;
}
mochachino.final = function() {
after(function() {
setTimeout(function(){
mochachino.exit();
}, 1000);
});
}