Simon Priet 9e2991e668 init
2021-09-05 22:53:58 +02:00

28 lines
754 B
JavaScript

const { shouldProceedCurrentStep } = require("./tagsHelper");
class HookRegistry {
constructor() {
this.definitions = [];
this.runtime = {};
this.runtime = (tags, implementation) => {
this.definitions.push({
tags,
implementation,
featureName: window.currentFeatureName || "___GLOBAL_EXECUTION___",
});
};
this.resolve = (scenarioTags, runningFeatureName) =>
this.definitions.filter(
({ tags, featureName }) =>
(!tags ||
tags.length === 0 ||
shouldProceedCurrentStep(scenarioTags, tags)) &&
(runningFeatureName === featureName ||
featureName === "___GLOBAL_EXECUTION___")
);
}
}
exports.HookRegistry = HookRegistry;