darvin-testing-framework
Advanced tools
Comparing version 1.3.0 to 1.4.0
36
index.js
@@ -18,3 +18,3 @@ 'use strict'; | ||
if (!spec.name) { | ||
throw Error(`Tried to execute a spec without a name.`); | ||
throw Error('Tried to execute a spec without a name.'); | ||
} | ||
@@ -38,9 +38,16 @@ | ||
that._validateScenario(spec, scenario); | ||
it(scenario.it, done => that._executeScenario(spec, scenario, done)); | ||
Object.keys(scenario).forEach(key => { | ||
switch (key) { | ||
case 'it': | ||
it(scenario.it, done => that._executeScenario(spec, scenario, done)); | ||
break; | ||
case 'fit': | ||
fit(scenario.fit, done => that._executeScenario(spec, scenario, done)); | ||
break; | ||
} | ||
}); | ||
}); | ||
if (spec.dynamic && typeof spec.dynamic === 'function') { | ||
const sender = { | ||
id: 'tempuser-' + uuid() | ||
}; | ||
const sender = this._getSender(); | ||
const context = { | ||
@@ -56,8 +63,8 @@ send: message => this._send(spec, sender, message) | ||
_validateScenario(spec, scenario) { | ||
if (!scenario.it) { | ||
throw Error(`The spec '${spec.name}' has a scenario without description in 'it'.`); | ||
if (!scenario.it && !scenario.fit) { | ||
throw Error(`The spec '${spec.name}' has a scenario without description in 'it' / 'fit'.`); | ||
} | ||
if (!scenario.steps) { | ||
throw Error(`The spec '${spec.name}' has a scenario without 'steps' in it.`); | ||
throw Error(`The spec '${spec.name}' has a scenario without 'steps'.`); | ||
} | ||
@@ -76,5 +83,3 @@ } | ||
const that = this; | ||
const sender = { | ||
id: 'tempuser-' + uuid() | ||
}; | ||
const sender = this._getSender(spec.sender); | ||
@@ -86,2 +91,9 @@ BbPromise.each(scenario.steps, step => that._executeStep(spec, scenario, step, sender)) | ||
_getSender(sender) { | ||
const name = sender && sender.name || 'test-user'; | ||
const id = `${sender && sender.id || name}-${sender && sender.uuid || uuid()}`; | ||
return { id, name }; | ||
} | ||
_executeStep(spec, scenario, step, sender) { | ||
@@ -134,2 +146,2 @@ const message = Object.assign({}, step.user, { | ||
module.exports = TestingFramework; | ||
module.exports = TestingFramework; |
{ | ||
"name": "darvin-testing-framework", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "A framework for testing Darvin.ai bots.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13794
132