-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathStepLevelPlugin.js
57 lines (48 loc) · 1.62 KB
/
StepLevelPlugin.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
'use strict';
var $ = require('../../Array');
var Platform = require('../../Platform');
var BasePlugin = require('./BasePlugin');
module.exports.init = function (options) {
// eslint-disable-next-line no-redeclare
var options = options || {};
var platform = new Platform();
var container = options.container || platform.get_container();
var base_plugin = BasePlugin.create(options);
function scenarios(scenarios, iterator) {
$(scenarios).each(function (scenario) {
base_plugin.describe(scenario.title, scenario, iterator);
});
}
function steps(steps, iterator) {
var abort = false;
$(steps).each(function (step) {
var stepFn = iterator.length === 1 ? step_sync : step_async;
stepFn(step, iterator);
});
function step_async(step, iterator) {
base_plugin.it_async(step, step, function (context, step, done) {
if (abort) {
return context.skip ? context.skip() : done();
}
abort = true;
iterator.bind(context)(step, function (err) {
if (err) return (done.fail || done)(err);
abort = false;
done();
});
});
}
function step_sync(step, iterator) {
base_plugin.it_sync(step, step, function (context, step) {
if (abort) return context.skip && context.skip();
abort = true;
iterator.bind(context)(step);
abort = false;
});
}
}
container.featureFiles = container.featureFile = base_plugin.featureFiles;
container.features = container.feature = base_plugin.features;
container.scenarios = container.scenario = scenarios;
container.steps = steps;
};