This repository was archived by the owner on Sep 21, 2022. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathsuite.js
More file actions
95 lines (76 loc) · 1.92 KB
/
Copy pathsuite.js
File metadata and controls
95 lines (76 loc) · 1.92 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
A29E
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
'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() {};
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;
}
});
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;
};