Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("should return an empty string for a reply without a simple response", () => {
const suggestions = new Suggestions("suggestion");
const richResponse = new RichResponse();
richResponse.addSuggestion(suggestions);
reply.payload.google.richResponse = richResponse;
expect(reply.speech).to.equal("");
});
});
it("should return true for a reply with a card", () => {
const card = new BasicCard({});
const richResponse = new RichResponse();
richResponse.add(card);
reply.payload.google.richResponse = richResponse;
expect(reply.hasDirectives).to.be.true;
expect(reply.hasDirective("BasicCard")).to.be.true;
});
protected getSimpleResponse(): GoogleActionsV2SimpleResponse {
const richResponse = this.payload.google.richResponse || new RichResponse();
this.payload.google.richResponse = richResponse;
const simpleResponseItem = _.find(
richResponse.items,
(item) => !!item.simpleResponse,
);
if (simpleResponseItem && simpleResponseItem.simpleResponse) {
return simpleResponseItem.simpleResponse;
}
const simpleResponse = new SimpleResponse("");
richResponse.add(simpleResponse);
return simpleResponse;
public async writeToReply(
reply: IVoxaReply,
event: IVoxaEvent,
transition: ITransition,
): Promise {
const google = (reply as DialogflowReply).payload.google;
let richResponse: RichResponse = google.richResponse;
if (!richResponse) {
richResponse = new RichResponse([]);
}
google.richResponse = richResponse;
let viewPaths = this.viewPaths;
if (_.isString(viewPaths)) {
viewPaths = [viewPaths];
}
await bluebird.mapSeries(viewPaths, async (view: string) => {
const statement = await event.renderer.renderPath(view, event);
if (transition.dialogflowSplitSimpleResponses) {
richResponse.add(new SimpleResponse(""));
}
reply.addStatement(sampleOrItem(statement, event.platform));
});
}