darvin-testing-framework
Advanced tools
Comparing version 1.8.1 to 1.10.0
29
index.js
@@ -131,10 +131,11 @@ 'use strict'; | ||
message = this._formatMessage(message, scenario.parameters); | ||
const context = Object.assign({}, scenario.parameters, { spec }); | ||
message = this._formatMessage(message, context); | ||
return this._send(spec, sender, message) | ||
.then(response => this._verifyStep(step, response, scenario.parameters)); | ||
.then(response => this._verifyStep(step, response, context)); | ||
} | ||
_send(spec, sender, message) { | ||
const channelUrl = `${this._apiUrl}v1/bots/${spec.botId}/channels/${spec.channel.id}/darvin`; | ||
const channelUrl = `${this._apiUrl}v1/bots/${spec.proxyBotId || spec.botId}/channels/${spec.channel.id}/darvin`; | ||
const payload = { | ||
@@ -211,9 +212,23 @@ sender, | ||
switch (key) { | ||
case 'text': | ||
case 'text': { | ||
const expectedText = expectedResponse.text; | ||
if (Array.isArray(expectedText)) { | ||
return expectedText.includes(actualResponse.text); | ||
} else { | ||
return expectedText === actualResponse.text; | ||
} | ||
return expectedText === actualResponse.text; | ||
} | ||
case 'textStartsWith': { | ||
const expectedText = expectedResponse.textStartsWith; | ||
return actualResponse.text.startsWith(expectedText); | ||
} | ||
case 'textIncludes': { | ||
const expectedText = expectedResponse.textContains; | ||
if (Array.isArray(expectedText)) { | ||
return expectedText.reduce((accumulator, currentValue) => accumulator && actualResponse.text.includes(currentValue)); | ||
} | ||
return actualResponse.text.includes(expectedText); | ||
} | ||
case 'template': | ||
@@ -223,3 +238,3 @@ return this._verify(expectedResponse.template, actualResponse.template, this._verifyTemplate.bind(this)); | ||
return JSON.stringify(expectedResponse[key]) === JSON.stringify(actualResponse[key]); | ||
}; | ||
} | ||
} | ||
@@ -226,0 +241,0 @@ |
{ | ||
"name": "darvin-testing-framework", | ||
"version": "1.8.1", | ||
"description": "A framework for testing Darvin.ai bots.", | ||
"version": "1.10.0", | ||
"description": "A framework for testing Kinvey Chat bots.", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "scripts": { |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
21742
239
3