UNPKG

skutter

Version:

Skutter: Opinionated BDD Browser based test framework

61 lines (60 loc) 1.77 kB
"use strict"; const Lazy = require("lazy.js"); const scenario_1 = require("./scenario"); const new_guid_1 = require("./services/new-guid"); const stop_watch_1 = require("./services/stop-watch"); class Feature { constructor(filename, title, annotations, description) { this._title = ""; this.dequeued = false; this.id = new_guid_1.newGuid(); this._filename = filename; this._title = title; this.annotations = Lazy(annotations).keys().map((key) => { return key; }).toArray(); this.dequeued = false; this._scenarios = new Array(); this.stopWatch = new stop_watch_1.StopWatch(); this._description = description; } get durationMiliseconds() { return this.stopWatch.elapsedMilliseconds; } get scenarios() { return this._scenarios; } get filename() { return this._filename; } get title() { return this._title; } get queued() { if (this.dequeued) { return false; } if (!Lazy(this.scenarios).where((scenario) => { return scenario.queued; }).some()) { return false; } return !Lazy(this.annotations).contains("pending"); } appendScenario(title, annotations, steps) { let scenario = new scenario_1.Scenario(title, annotations, new_guid_1.newGuid()); for (let step of steps) { scenario.appendStep(step); } this.scenarios.push(scenario); } start() { this.stopWatch.start(); } stop() { this.stopWatch.stop(); } dequeue() { this.dequeued = true; for (let scenario of this.scenarios) { scenario.dequeue(); } } } exports.Feature = Feature;