forked from gemini-testing/gemini
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsuite.js
More file actions
109 lines (88 loc) · 2.28 KB
/
Copy pathsuite.js
File metadata and controls
109 lines (88 loc) · 2.28 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
108
109
'use strict';
var inherit = require('inherit');
function definePrivate(suite) {
Object.defineProperty(suite, '_states', {
writable: false,
enumerable: false,
value: []
});
Object.defineProperty(suite, '_children', {
writable: false,
enumerable: false,
value: []
});
}
var Suite = inherit({
__constructor: function(name) {
this.name = name;
this.url = null;
this.skipped = false;
this.captureSelectors = null;
this.beforeHook = function() {};
this.afterHook = function() {};
definePrivate(this);
},
addState: function(state) {
this._states.push(state);
},
skip: function(browsersList) {
if (this.skipped === true) {
return;
}
if (!browsersList) {
this.skipped = true;
} else if (Array.isArray(this.skipped)) {
this.skipped = this.skipped.concat(browsersList);
} else {
this.skipped = browsersList;
}
},
hasChildNamed: function(name) {
return this._hasNamed(this._children, name);
},
hasStateNamed: function(name) {
return this._hasNamed(this._states, name);
},
_hasNamed: function(collection, name) {
return collection.some(function(item) {
return item.name === name;
});
},
get states() {
return this._states;
},
get children() {
return this._children;
},
addChild: function(suite) {
suite.parent = this;
this._children.push(suite);
},
get hasStates() {
return this._states.length > 0;
},
get isRoot() {
return !this.parent;
},
get deepStatesCount() {
return this._children.reduce(function(sum, child) {
return sum + child.deepStatesCount;
}, this._states.length);
},
get fullName() {
if (!this.parent) {
return this.name;
}
return this.parent.fullName + ' ' + this.name;
}
});
exports.create = function createSuite(name, parent) {
if (!parent) {
return new Suite(name);
}
var suite = Object.create(parent);
definePrivate(suite);
suite.name = name;
parent.addChild(suite);
return suite;
};