Skip to content

Commit

Permalink
Finished minor test for single prompt to set up harness
Browse files Browse the repository at this point in the history
  • Loading branch information
szul committed Oct 7, 2018
1 parent 77fee35 commit 8c2c984
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}\\libraries\\botbuilder-dialog-prompts\\test\\bot.js",
"program": "${workspaceFolder}\\libraries\\botbuilder-dialog-prompts\\test\\index.js",
"outFiles": [
"${workspaceFolder}/**/*.js"
]//,
Expand Down
4 changes: 3 additions & 1 deletion libraries/botbuilder-dialog-prompts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
"@microsoft/recognizers-text-sequence": "^1.1.3",
"botbuilder": "^4.0.6",
"botbuilder-core": "^4.0.6",
"botbuilder-dialogs": "^4.0.6",
"botbuilder-dialogs": "^4.0.6"
},
"devDependencies": {
"mocha": "^5.2.0"
}
}
6 changes: 3 additions & 3 deletions libraries/botbuilder-dialog-prompts/test/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { BotFrameworkAdapter, ConversationState, MemoryStorage } = require("botbuilder");
const restify = require("restify");
const { TestBot } = require("../test");
const { EmailBot } = require("../email");

const server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function () {
Expand All @@ -15,10 +15,10 @@ const adapter = new BotFrameworkAdapter({
const memoryStorage = new MemoryStorage();
const conversationState = new ConversationState(memoryStorage);

const testBot = new TestBot(conversationState);
const emailBot = new EmailBot(conversationState);

server.post("/api/messages", (req, res) => {
adapter.processActivity(req, res, async (context) => {
await testBot.onTurn(context);
await emailBot.onTurn(context);
});
});
8 changes: 5 additions & 3 deletions libraries/botbuilder-dialog-prompts/test/test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const { DialogSet, WaterfallDialog } = require("botbuilder-dialogs");
const { EmailPrompt } = require("@botbuildercommunity/dialog-prompts");

class TestBot {
class EmailBot {
constructor(conversationState) {
this.conversationState = conversationState;
this.dialogState = conversationState.createProperty("dialogState");
this.dialogs = new DialogSet(dialogState);
this.dialogs = new DialogSet(this.dialogState);
this.dialogs.add(new WaterfallDialog("email", [
async (step) => {
return await step.prompt("emailPrompt", "What is your email address?");
Expand All @@ -18,7 +18,7 @@ class TestBot {
this.dialogs.add(new EmailPrompt("emailPrompt"));
}
async onTurn(context) {
const dc = await dialogs.createContext(context);
const dc = await this.dialogs.createContext(context);
if (!context.responded) {
await dc.continueDialog();
}
Expand All @@ -30,3 +30,5 @@ class TestBot {
await this.conversationState.saveChanges(context);
}
}

module.exports.EmailBot = EmailBot;

0 comments on commit 8c2c984

Please sign in to comment.