@sprucelabs/spruce-conversation-plugin 62.2.24 → 62.2.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +17 -17
- package/build/__tests__/behavioral/CheckingHealth.test.d.ts +0 -10
- package/build/__tests__/behavioral/CheckingHealth.test.js +0 -87
- package/build/__tests__/behavioral/KillingASkill.test.d.ts +0 -4
- package/build/__tests__/behavioral/KillingASkill.test.js +0 -29
- package/build/__tests__/behavioral/RegisteringConversationsOnBoot.test.d.ts +0 -13
- package/build/__tests__/behavioral/RegisteringConversationsOnBoot.test.js +0 -147
- package/build/__tests__/behavioral/RespondingToMessages.test.d.ts +0 -13
- package/build/__tests__/behavioral/RespondingToMessages.test.js +0 -134
- package/build/__tests__/behavioral/TestingAConversation.test.d.ts +0 -14
- package/build/__tests__/behavioral/TestingAConversation.test.js +0 -110
- package/build/__tests__/implementation/ConversationCoordinator.test.d.ts +0 -18
- package/build/__tests__/implementation/ConversationCoordinator.test.js +0 -185
- package/build/__tests__/implementation/MessageGraphicsInterface/EmailField.test.d.ts +0 -7
- package/build/__tests__/implementation/MessageGraphicsInterface/EmailField.test.js +0 -73
- package/build/__tests__/implementation/MessageGraphicsInterface/MessageGraphicsInterface.test.d.ts +0 -4
- package/build/__tests__/implementation/MessageGraphicsInterface/MessageGraphicsInterface.test.js +0 -42
- package/build/__tests__/implementation/MessageGraphicsInterface/MockMessageBeforeAndAfterEach.test.d.ts +0 -5
- package/build/__tests__/implementation/MessageGraphicsInterface/MockMessageBeforeAndAfterEach.test.js +0 -62
- package/build/__tests__/implementation/MessageGraphicsInterface/MockMessageInterface.test.d.ts +0 -18
- package/build/__tests__/implementation/MessageGraphicsInterface/MockMessageInterface.test.js +0 -168
- package/build/__tests__/implementation/MessageGraphicsInterface/SelectField.test.d.ts +0 -7
- package/build/__tests__/implementation/MessageGraphicsInterface/SelectField.test.js +0 -71
- package/build/__tests__/implementation/MessageGraphicsInterface/TextField.test.d.ts +0 -6
- package/build/__tests__/implementation/MessageGraphicsInterface/TextField.test.js +0 -48
- package/build/__tests__/implementation/ScriptTester.test.d.ts +0 -19
- package/build/__tests__/implementation/ScriptTester.test.js +0 -461
- package/build/__tests__/implementation/SuggesterUtil.test.d.ts +0 -7
- package/build/__tests__/implementation/SuggesterUtil.test.js +0 -63
- package/build/__tests__/implementation/TopicLoader.test.d.ts +0 -8
- package/build/__tests__/implementation/TopicLoader.test.js +0 -66
- package/build/__tests__/implementation/TopicScriptPlayer.test.d.ts +0 -23
- package/build/__tests__/implementation/TopicScriptPlayer.test.js +0 -436
- package/build/__tests__/implementation/TopicSuggester.test.d.ts +0 -8
- package/build/__tests__/implementation/TopicSuggester.test.js +0 -137
- package/build/__tests__/testDirsAndFiles/bad-empty/conversations/bookAppointment.topic.d.ts +0 -0
- package/build/__tests__/testDirsAndFiles/bad-empty/conversations/bookAppointment.topic.js +0 -1
- package/build/__tests__/testDirsAndFiles/bad-missing-params/conversations/bookAppointment.topic.d.ts +0 -2
- package/build/__tests__/testDirsAndFiles/bad-missing-params/conversations/bookAppointment.topic.js +0 -4
- package/build/__tests__/testDirsAndFiles/bad-skill/build/.spruce/events/listeners.d.ts +0 -2
- package/build/__tests__/testDirsAndFiles/bad-skill/build/.spruce/events/listeners.js +0 -3
- package/build/__tests__/testDirsAndFiles/bad-skill/build/conversations/bookAppointment.topic.d.ts +0 -2
- package/build/__tests__/testDirsAndFiles/bad-skill/build/conversations/bookAppointment.topic.js +0 -4
- package/build/__tests__/testDirsAndFiles/empty-skill/build/.spruce/events/listeners.d.ts +0 -2
- package/build/__tests__/testDirsAndFiles/empty-skill/build/.spruce/events/listeners.js +0 -3
- package/build/__tests__/testDirsAndFiles/good/conversations/bookAppointment.topic.d.ts +0 -3
- package/build/__tests__/testDirsAndFiles/good/conversations/bookAppointment.topic.js +0 -8
- package/build/__tests__/testDirsAndFiles/good/conversations/cancelAppointment.topic.d.ts +0 -3
- package/build/__tests__/testDirsAndFiles/good/conversations/cancelAppointment.topic.js +0 -12
- package/build/__tests__/testDirsAndFiles/skill/build/.spruce/events/listeners.d.ts +0 -2
- package/build/__tests__/testDirsAndFiles/skill/build/.spruce/events/listeners.js +0 -3
- package/build/__tests__/testDirsAndFiles/skill/build/conversations/bookAppointment.topic.d.ts +0 -3
- package/build/__tests__/testDirsAndFiles/skill/build/conversations/bookAppointment.topic.js +0 -8
- package/build/__tests__/testDirsAndFiles/skill/build/conversations/cancelAppointment.topic.d.ts +0 -3
- package/build/__tests__/testDirsAndFiles/skill/build/conversations/cancelAppointment.topic.js +0 -12
- package/build/__tests__/testDirsAndFiles/skill/build/conversations/favoriteColor.topic.d.ts +0 -3
- package/build/__tests__/testDirsAndFiles/skill/build/conversations/favoriteColor.topic.js +0 -21
- package/build/__tests__/testDirsAndFiles/skill/build/conversations/favoriteColorTopicChanger.topic.d.ts +0 -3
- package/build/__tests__/testDirsAndFiles/skill/build/conversations/favoriteColorTopicChanger.topic.js +0 -21
- package/build/__tests__/testDirsAndFiles/skill/build/conversations/mixedStringsAndCallbacks.topic.d.ts +0 -3
- package/build/__tests__/testDirsAndFiles/skill/build/conversations/mixedStringsAndCallbacks.topic.js +0 -29
- package/build/__tests__/testDirsAndFiles/skill-assertions/build/.spruce/events/listeners.d.ts +0 -2
- package/build/__tests__/testDirsAndFiles/skill-assertions/build/.spruce/events/listeners.js +0 -3
- package/build/__tests__/testDirsAndFiles/skill-assertions/build/conversations/assertsScriptCallbackOptions.topic.d.ts +0 -3
- package/build/__tests__/testDirsAndFiles/skill-assertions/build/conversations/assertsScriptCallbackOptions.topic.js +0 -22
- package/build/__tests__/testDirsAndFiles/skill-assertions/build/conversations/assertsScriptOnlyCalledOnce.topic.d.ts +0 -3
- package/build/__tests__/testDirsAndFiles/skill-assertions/build/conversations/assertsScriptOnlyCalledOnce.topic.js +0 -14
- package/build/__tests__/testDirsAndFiles/skill-with-one-topic/build/.spruce/events/listeners.d.ts +0 -2
- package/build/__tests__/testDirsAndFiles/skill-with-one-topic/build/.spruce/events/listeners.js +0 -3
- package/build/__tests__/testDirsAndFiles/skill-with-one-topic/build/conversations/bookAppointment.topic.d.ts +0 -3
- package/build/__tests__/testDirsAndFiles/skill-with-one-topic/build/conversations/bookAppointment.topic.js +0 -8
- package/build/__tests__/testDirsAndFiles/skill-with-script-that-throws/build/.spruce/events/listeners.d.ts +0 -2
- package/build/__tests__/testDirsAndFiles/skill-with-script-that-throws/build/.spruce/events/listeners.js +0 -3
- package/build/__tests__/testDirsAndFiles/skill-with-script-that-throws/build/conversations/cancelAppointment.topic.d.ts +0 -3
- package/build/__tests__/testDirsAndFiles/skill-with-script-that-throws/build/conversations/cancelAppointment.topic.js +0 -16
- package/build/esm/__tests__/behavioral/CheckingHealth.test.d.ts +0 -10
- package/build/esm/__tests__/behavioral/CheckingHealth.test.js +0 -104
- package/build/esm/__tests__/behavioral/KillingASkill.test.d.ts +0 -4
- package/build/esm/__tests__/behavioral/KillingASkill.test.js +0 -34
- package/build/esm/__tests__/behavioral/RegisteringConversationsOnBoot.test.d.ts +0 -13
- package/build/esm/__tests__/behavioral/RegisteringConversationsOnBoot.test.js +0 -171
- package/build/esm/__tests__/behavioral/RespondingToMessages.test.d.ts +0 -13
- package/build/esm/__tests__/behavioral/RespondingToMessages.test.js +0 -158
- package/build/esm/__tests__/behavioral/TestingAConversation.test.d.ts +0 -14
- package/build/esm/__tests__/behavioral/TestingAConversation.test.js +0 -137
- package/build/esm/__tests__/implementation/ConversationCoordinator.test.d.ts +0 -18
- package/build/esm/__tests__/implementation/ConversationCoordinator.test.js +0 -214
- package/build/esm/__tests__/implementation/MessageGraphicsInterface/EmailField.test.d.ts +0 -7
- package/build/esm/__tests__/implementation/MessageGraphicsInterface/EmailField.test.js +0 -84
- package/build/esm/__tests__/implementation/MessageGraphicsInterface/MessageGraphicsInterface.test.d.ts +0 -4
- package/build/esm/__tests__/implementation/MessageGraphicsInterface/MessageGraphicsInterface.test.js +0 -47
- package/build/esm/__tests__/implementation/MessageGraphicsInterface/MockMessageBeforeAndAfterEach.test.d.ts +0 -5
- package/build/esm/__tests__/implementation/MessageGraphicsInterface/MockMessageBeforeAndAfterEach.test.js +0 -47
- package/build/esm/__tests__/implementation/MessageGraphicsInterface/MockMessageInterface.test.d.ts +0 -18
- package/build/esm/__tests__/implementation/MessageGraphicsInterface/MockMessageInterface.test.js +0 -172
- package/build/esm/__tests__/implementation/MessageGraphicsInterface/SelectField.test.d.ts +0 -7
- package/build/esm/__tests__/implementation/MessageGraphicsInterface/SelectField.test.js +0 -80
- package/build/esm/__tests__/implementation/MessageGraphicsInterface/TextField.test.d.ts +0 -6
- package/build/esm/__tests__/implementation/MessageGraphicsInterface/TextField.test.js +0 -57
- package/build/esm/__tests__/implementation/ScriptTester.test.d.ts +0 -19
- package/build/esm/__tests__/implementation/ScriptTester.test.js +0 -470
- package/build/esm/__tests__/implementation/SuggesterUtil.test.d.ts +0 -7
- package/build/esm/__tests__/implementation/SuggesterUtil.test.js +0 -74
- package/build/esm/__tests__/implementation/TopicLoader.test.d.ts +0 -8
- package/build/esm/__tests__/implementation/TopicLoader.test.js +0 -79
- package/build/esm/__tests__/implementation/TopicScriptPlayer.test.d.ts +0 -23
- package/build/esm/__tests__/implementation/TopicScriptPlayer.test.js +0 -477
- package/build/esm/__tests__/implementation/TopicSuggester.test.d.ts +0 -8
- package/build/esm/__tests__/implementation/TopicSuggester.test.js +0 -130
- package/build/esm/__tests__/testDirsAndFiles/bad-empty/conversations/bookAppointment.topic.d.ts +0 -0
- package/build/esm/__tests__/testDirsAndFiles/bad-empty/conversations/bookAppointment.topic.js +0 -1
- package/build/esm/__tests__/testDirsAndFiles/bad-missing-params/conversations/bookAppointment.topic.d.ts +0 -2
- package/build/esm/__tests__/testDirsAndFiles/bad-missing-params/conversations/bookAppointment.topic.js +0 -2
- package/build/esm/__tests__/testDirsAndFiles/bad-skill/build/conversations/bookAppointment.topic.d.ts +0 -2
- package/build/esm/__tests__/testDirsAndFiles/bad-skill/build/conversations/bookAppointment.topic.js +0 -2
- package/build/esm/__tests__/testDirsAndFiles/good/conversations/bookAppointment.topic.d.ts +0 -3
- package/build/esm/__tests__/testDirsAndFiles/good/conversations/bookAppointment.topic.js +0 -6
- package/build/esm/__tests__/testDirsAndFiles/good/conversations/cancelAppointment.topic.d.ts +0 -3
- package/build/esm/__tests__/testDirsAndFiles/good/conversations/cancelAppointment.topic.js +0 -10
- package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/bookAppointment.topic.d.ts +0 -3
- package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/bookAppointment.topic.js +0 -6
- package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/cancelAppointment.topic.d.ts +0 -3
- package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/cancelAppointment.topic.js +0 -10
- package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/favoriteColor.topic.d.ts +0 -3
- package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/favoriteColor.topic.js +0 -28
- package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/favoriteColorTopicChanger.topic.d.ts +0 -3
- package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/favoriteColorTopicChanger.topic.js +0 -28
- package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/mixedStringsAndCallbacks.topic.d.ts +0 -3
- package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/mixedStringsAndCallbacks.topic.js +0 -36
- package/build/esm/__tests__/testDirsAndFiles/skill-assertions/build/conversations/assertsScriptCallbackOptions.topic.d.ts +0 -3
- package/build/esm/__tests__/testDirsAndFiles/skill-assertions/build/conversations/assertsScriptCallbackOptions.topic.js +0 -29
- package/build/esm/__tests__/testDirsAndFiles/skill-assertions/build/conversations/assertsScriptOnlyCalledOnce.topic.d.ts +0 -3
- package/build/esm/__tests__/testDirsAndFiles/skill-assertions/build/conversations/assertsScriptOnlyCalledOnce.topic.js +0 -21
- package/build/esm/__tests__/testDirsAndFiles/skill-with-one-topic/build/conversations/bookAppointment.topic.d.ts +0 -3
- package/build/esm/__tests__/testDirsAndFiles/skill-with-one-topic/build/conversations/bookAppointment.topic.js +0 -6
- package/build/esm/__tests__/testDirsAndFiles/skill-with-script-that-throws/build/conversations/cancelAppointment.topic.d.ts +0 -3
- package/build/esm/__tests__/testDirsAndFiles/skill-with-script-that-throws/build/conversations/cancelAppointment.topic.js +0 -14
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
13
|
-
const AbstractGraphicsInterfaceTest_1 = __importDefault(require("../../../tests/AbstractGraphicsInterfaceTest"));
|
|
14
|
-
class TextFieldTest extends AbstractGraphicsInterfaceTest_1.default {
|
|
15
|
-
static async promptSendsLabel() {
|
|
16
|
-
void this.ui.prompt({
|
|
17
|
-
type: 'text',
|
|
18
|
-
label: 'Tell me about your life.',
|
|
19
|
-
});
|
|
20
|
-
test_utils_1.assert.doesInclude(this.sentMessages, {
|
|
21
|
-
body: 'Tell me about your life.',
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
static async noPromptSendsNoMessage() {
|
|
25
|
-
void this.ui.prompt({
|
|
26
|
-
type: 'text',
|
|
27
|
-
});
|
|
28
|
-
test_utils_1.assert.isLength(this.sentMessages, 0);
|
|
29
|
-
}
|
|
30
|
-
static async canRespondToPrompt() {
|
|
31
|
-
const promise = this.ui.prompt({
|
|
32
|
-
type: 'text',
|
|
33
|
-
});
|
|
34
|
-
await this.sendMessage('hey there!');
|
|
35
|
-
const answer = await promise;
|
|
36
|
-
test_utils_1.assert.isEqual(answer, 'hey there!');
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
exports.default = TextFieldTest;
|
|
40
|
-
__decorate([
|
|
41
|
-
(0, test_utils_1.test)()
|
|
42
|
-
], TextFieldTest, "promptSendsLabel", null);
|
|
43
|
-
__decorate([
|
|
44
|
-
(0, test_utils_1.test)()
|
|
45
|
-
], TextFieldTest, "noPromptSendsNoMessage", null);
|
|
46
|
-
__decorate([
|
|
47
|
-
(0, test_utils_1.test)()
|
|
48
|
-
], TextFieldTest, "canRespondToPrompt", null);
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import AbstractConversationTest from '../../tests/AbstractConversationTest';
|
|
2
|
-
import { Script } from '../../types/conversation.types';
|
|
3
|
-
export default class ScriptTesterTest extends AbstractConversationTest {
|
|
4
|
-
private static readonly basicBookingScript;
|
|
5
|
-
protected static throwsWithoutScript(): Promise<void>;
|
|
6
|
-
protected static acceptsSimpleScript(): Promise<void>;
|
|
7
|
-
protected static callingGoDoesntCrash(): Promise<void>;
|
|
8
|
-
protected static cantHandleMessageBeforeStartup(): Promise<void>;
|
|
9
|
-
protected static selectingBadScriptToStartThrows(): Promise<void>;
|
|
10
|
-
protected static asksWhichScriptYouWantToStartWithWhenThereIsMoreThanOne(): Promise<void>;
|
|
11
|
-
protected static playsSimpleScript(script: Script): Promise<void>;
|
|
12
|
-
protected static canSendInputToThePlayer(answer: string): Promise<void>;
|
|
13
|
-
protected static promptsForFirstMessageIfNoneSentToGo(): Promise<void>;
|
|
14
|
-
protected static showsConfidenceRatingBasedOnFirstMesageSent(): Promise<void>;
|
|
15
|
-
protected static promptsToStartAgainAfterDone(): Promise<void>;
|
|
16
|
-
protected static messagesAboutTransitionResponseTopicChanger(): Promise<void>;
|
|
17
|
-
protected static messagesAboutTransitionResponseWithRepairs(): Promise<void>;
|
|
18
|
-
private static Tester;
|
|
19
|
-
}
|
|
@@ -1,461 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
-
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
-
if (mod && mod.__esModule) return mod;
|
|
26
|
-
var result = {};
|
|
27
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
-
__setModuleDefault(result, mod);
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
32
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
33
|
-
};
|
|
34
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
36
|
-
const AbstractConversationTest_1 = __importDefault(require("../../tests/AbstractConversationTest"));
|
|
37
|
-
const ScriptTester_1 = __importStar(require("../../tests/ScriptTester"));
|
|
38
|
-
class ScriptTesterTest extends AbstractConversationTest_1.default {
|
|
39
|
-
static async throwsWithoutScript() {
|
|
40
|
-
//@ts-ignore
|
|
41
|
-
const err = await test_utils_1.assert.doesThrowAsync(() => ScriptTester_1.default.Tester());
|
|
42
|
-
test_utils_1.errorAssert.assertError(err, 'MISSING_PARAMETERS', {
|
|
43
|
-
parameters: ['script'],
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
static async acceptsSimpleScript() {
|
|
47
|
-
const tester = await ScriptTesterTest.Tester({
|
|
48
|
-
topics: [
|
|
49
|
-
{
|
|
50
|
-
utterances: [],
|
|
51
|
-
key: 'bookAppointment',
|
|
52
|
-
label: 'Book appointment',
|
|
53
|
-
script: ['hey there!'],
|
|
54
|
-
},
|
|
55
|
-
],
|
|
56
|
-
});
|
|
57
|
-
test_utils_1.assert.isTruthy(tester);
|
|
58
|
-
}
|
|
59
|
-
static async callingGoDoesntCrash() {
|
|
60
|
-
const tester = await this.Tester({
|
|
61
|
-
topics: [
|
|
62
|
-
{
|
|
63
|
-
utterances: [],
|
|
64
|
-
key: 'bookAppointment',
|
|
65
|
-
label: 'Book appointment',
|
|
66
|
-
script: ['hey there!'],
|
|
67
|
-
},
|
|
68
|
-
],
|
|
69
|
-
writeHandler: () => { },
|
|
70
|
-
selectPromptHandler: async () => '',
|
|
71
|
-
promptHandler: async () => await new Promise(() => { }),
|
|
72
|
-
});
|
|
73
|
-
void tester.go();
|
|
74
|
-
}
|
|
75
|
-
static async cantHandleMessageBeforeStartup() {
|
|
76
|
-
const tester = await this.Tester({
|
|
77
|
-
topics: [
|
|
78
|
-
{
|
|
79
|
-
utterances: [],
|
|
80
|
-
key: 'bookAppointment',
|
|
81
|
-
label: 'Book appointment',
|
|
82
|
-
script: ['hey there!'],
|
|
83
|
-
},
|
|
84
|
-
],
|
|
85
|
-
writeHandler: () => { },
|
|
86
|
-
selectPromptHandler: async () => '',
|
|
87
|
-
promptHandler: async () => '',
|
|
88
|
-
});
|
|
89
|
-
const err = await test_utils_1.assert.doesThrowAsync(() => tester.handleInput('taco'));
|
|
90
|
-
test_utils_1.errorAssert.assertError(err, 'TESTER_NOT_STARTED');
|
|
91
|
-
}
|
|
92
|
-
static async selectingBadScriptToStartThrows() {
|
|
93
|
-
const tester = await this.Tester({
|
|
94
|
-
topics: this.basicBookingScript,
|
|
95
|
-
selectPromptHandler: async () => {
|
|
96
|
-
return 'oeuou';
|
|
97
|
-
},
|
|
98
|
-
writeHandler: () => { },
|
|
99
|
-
promptHandler: async () => '',
|
|
100
|
-
});
|
|
101
|
-
const err = await test_utils_1.assert.doesThrowAsync(() => tester.go());
|
|
102
|
-
test_utils_1.errorAssert.assertError(err, 'TOPIC_NOT_FOUND', {
|
|
103
|
-
suppliedTopic: 'oeuou',
|
|
104
|
-
validTopics: ['bookAppointment', 'cancelAppointment'],
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
static async asksWhichScriptYouWantToStartWithWhenThereIsMoreThanOne() {
|
|
108
|
-
let choices;
|
|
109
|
-
const writes = [];
|
|
110
|
-
const tester = await this.Tester({
|
|
111
|
-
topics: this.basicBookingScript,
|
|
112
|
-
selectPromptHandler: async (message) => {
|
|
113
|
-
var _a;
|
|
114
|
-
choices = (_a = message.choices) !== null && _a !== void 0 ? _a : [];
|
|
115
|
-
return 'cancelAppointment';
|
|
116
|
-
},
|
|
117
|
-
writeHandler: (message) => {
|
|
118
|
-
writes.push(message.body);
|
|
119
|
-
},
|
|
120
|
-
promptHandler: async () => await new Promise(() => { }),
|
|
121
|
-
});
|
|
122
|
-
void tester.go('go team');
|
|
123
|
-
test_utils_1.assert.isEqualDeep(choices, [
|
|
124
|
-
{
|
|
125
|
-
value: 'bookAppointment',
|
|
126
|
-
label: 'Book appointment',
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
value: 'cancelAppointment',
|
|
130
|
-
label: 'Cancel appointment',
|
|
131
|
-
},
|
|
132
|
-
]);
|
|
133
|
-
await this.wait(10);
|
|
134
|
-
test_utils_1.assert.doesInclude(writes, 'Lets cancel');
|
|
135
|
-
}
|
|
136
|
-
static async playsSimpleScript(script) {
|
|
137
|
-
const writes = [];
|
|
138
|
-
const tester = await this.Tester({
|
|
139
|
-
shouldPlayReplayAfterFinish: false,
|
|
140
|
-
lineDelay: 0,
|
|
141
|
-
topics: [{ key: 'test', label: 'Testing', script, utterances: [] }],
|
|
142
|
-
writeHandler: (message) => {
|
|
143
|
-
writes.push(message.body);
|
|
144
|
-
},
|
|
145
|
-
selectPromptHandler: async () => '',
|
|
146
|
-
promptHandler: async () => '',
|
|
147
|
-
});
|
|
148
|
-
test_utils_1.assert.isLength(writes, 0);
|
|
149
|
-
void tester.go('hey there!');
|
|
150
|
-
await this.wait(10);
|
|
151
|
-
const expected = [
|
|
152
|
-
...script,
|
|
153
|
-
(0, ScriptTester_1.generateTransitionMessage)('discovery'),
|
|
154
|
-
ScriptTester_1.END_OF_LINE,
|
|
155
|
-
];
|
|
156
|
-
test_utils_1.assert.isLength(writes, expected.length);
|
|
157
|
-
test_utils_1.assert.isEqualDeep(writes, expected);
|
|
158
|
-
}
|
|
159
|
-
static async canSendInputToThePlayer(answer) {
|
|
160
|
-
const writes = [];
|
|
161
|
-
const tester = await this.Tester({
|
|
162
|
-
shouldPlayReplayAfterFinish: false,
|
|
163
|
-
topics: [
|
|
164
|
-
{
|
|
165
|
-
utterances: [],
|
|
166
|
-
key: 'test',
|
|
167
|
-
label: 'Test with prompt',
|
|
168
|
-
script: [
|
|
169
|
-
async (options) => {
|
|
170
|
-
const confirm = await options.ui.confirm('Are you sure?');
|
|
171
|
-
if (confirm) {
|
|
172
|
-
options.ui.renderLine('yes');
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
options.ui.renderLine('no');
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
|
-
],
|
|
179
|
-
},
|
|
180
|
-
],
|
|
181
|
-
writeHandler: (message) => {
|
|
182
|
-
writes.push(message.body);
|
|
183
|
-
},
|
|
184
|
-
promptHandler: async () => {
|
|
185
|
-
return answer;
|
|
186
|
-
},
|
|
187
|
-
selectPromptHandler: async () => '',
|
|
188
|
-
});
|
|
189
|
-
void tester.go('lets go!');
|
|
190
|
-
await this.wait(20);
|
|
191
|
-
const expected = [
|
|
192
|
-
'Are you sure?',
|
|
193
|
-
answer,
|
|
194
|
-
(0, ScriptTester_1.generateTransitionMessage)('discovery'),
|
|
195
|
-
ScriptTester_1.END_OF_LINE,
|
|
196
|
-
];
|
|
197
|
-
test_utils_1.assert.isEqualDeep(writes, expected);
|
|
198
|
-
}
|
|
199
|
-
static async promptsForFirstMessageIfNoneSentToGo() {
|
|
200
|
-
const writes = [];
|
|
201
|
-
const promptWrites = [];
|
|
202
|
-
let promptResolve;
|
|
203
|
-
const tester = await this.Tester({
|
|
204
|
-
lineDelay: 0,
|
|
205
|
-
topics: [
|
|
206
|
-
{
|
|
207
|
-
utterances: [],
|
|
208
|
-
key: 'test',
|
|
209
|
-
label: 'Test with prompt',
|
|
210
|
-
script: ['go', 'team'],
|
|
211
|
-
},
|
|
212
|
-
],
|
|
213
|
-
writeHandler: (message) => {
|
|
214
|
-
writes.push(message.body);
|
|
215
|
-
},
|
|
216
|
-
promptHandler: async (message) => {
|
|
217
|
-
promptWrites.push(message.body);
|
|
218
|
-
await new Promise((resolve) => (promptResolve = resolve));
|
|
219
|
-
return 'go!';
|
|
220
|
-
},
|
|
221
|
-
selectPromptHandler: async () => '',
|
|
222
|
-
});
|
|
223
|
-
void tester.go();
|
|
224
|
-
await this.wait(10);
|
|
225
|
-
test_utils_1.assert.isLength(promptWrites, 1);
|
|
226
|
-
test_utils_1.assert.isLength(writes, 0);
|
|
227
|
-
promptResolve();
|
|
228
|
-
await this.wait(10);
|
|
229
|
-
const expected = [
|
|
230
|
-
'go',
|
|
231
|
-
'team',
|
|
232
|
-
(0, ScriptTester_1.generateTransitionMessage)('discovery'),
|
|
233
|
-
ScriptTester_1.END_OF_LINE,
|
|
234
|
-
];
|
|
235
|
-
test_utils_1.assert.isEqualDeep(writes, expected);
|
|
236
|
-
}
|
|
237
|
-
static async showsConfidenceRatingBasedOnFirstMesageSent() {
|
|
238
|
-
const writes = [];
|
|
239
|
-
const promptWrites = [];
|
|
240
|
-
const tester = await this.Tester({
|
|
241
|
-
lineDelay: 0,
|
|
242
|
-
topics: [
|
|
243
|
-
{
|
|
244
|
-
utterances: ['go team', 'team'],
|
|
245
|
-
key: 'test',
|
|
246
|
-
label: 'Test with prompt',
|
|
247
|
-
script: ['go', 'team'],
|
|
248
|
-
},
|
|
249
|
-
],
|
|
250
|
-
writeHandler: (message) => {
|
|
251
|
-
writes.push(message.body);
|
|
252
|
-
},
|
|
253
|
-
promptHandler: async (message) => {
|
|
254
|
-
promptWrites.push(message.body);
|
|
255
|
-
return 'go!';
|
|
256
|
-
},
|
|
257
|
-
selectPromptHandler: async () => '',
|
|
258
|
-
});
|
|
259
|
-
void tester.go('team');
|
|
260
|
-
await this.wait(10);
|
|
261
|
-
test_utils_1.assert.doesInclude(writes, `%`);
|
|
262
|
-
}
|
|
263
|
-
static async promptsToStartAgainAfterDone() {
|
|
264
|
-
const writes = [];
|
|
265
|
-
let promptHitCount = 0;
|
|
266
|
-
const tester = await this.Tester({
|
|
267
|
-
lineDelay: 0,
|
|
268
|
-
topics: [
|
|
269
|
-
{
|
|
270
|
-
utterances: [],
|
|
271
|
-
key: 'test',
|
|
272
|
-
label: 'Test with prompt',
|
|
273
|
-
script: ['go', 'team'],
|
|
274
|
-
},
|
|
275
|
-
],
|
|
276
|
-
writeHandler: (message) => {
|
|
277
|
-
writes.push(message.body);
|
|
278
|
-
},
|
|
279
|
-
promptHandler: async () => {
|
|
280
|
-
promptHitCount++;
|
|
281
|
-
if (promptHitCount > 2) {
|
|
282
|
-
await new Promise(() => { });
|
|
283
|
-
}
|
|
284
|
-
return 'go!';
|
|
285
|
-
},
|
|
286
|
-
selectPromptHandler: async () => '',
|
|
287
|
-
});
|
|
288
|
-
void tester.go();
|
|
289
|
-
await this.wait(500);
|
|
290
|
-
test_utils_1.assert.isEqual(promptHitCount, 3);
|
|
291
|
-
test_utils_1.assert.isEqualDeep(writes, [
|
|
292
|
-
'go',
|
|
293
|
-
'team',
|
|
294
|
-
(0, ScriptTester_1.generateTransitionMessage)('discovery'),
|
|
295
|
-
ScriptTester_1.END_OF_LINE,
|
|
296
|
-
'go',
|
|
297
|
-
'team',
|
|
298
|
-
(0, ScriptTester_1.generateTransitionMessage)('discovery'),
|
|
299
|
-
ScriptTester_1.END_OF_LINE,
|
|
300
|
-
]);
|
|
301
|
-
}
|
|
302
|
-
static async messagesAboutTransitionResponseTopicChanger() {
|
|
303
|
-
const writes = [];
|
|
304
|
-
let promptHitCount = 0;
|
|
305
|
-
const tester = await this.Tester({
|
|
306
|
-
lineDelay: 0,
|
|
307
|
-
topics: [
|
|
308
|
-
{
|
|
309
|
-
key: 'test',
|
|
310
|
-
label: 'Test with prompt',
|
|
311
|
-
utterances: [],
|
|
312
|
-
script: [
|
|
313
|
-
'my',
|
|
314
|
-
'team',
|
|
315
|
-
async () => {
|
|
316
|
-
return {
|
|
317
|
-
transitionConversationTo: 'greeting',
|
|
318
|
-
topicChangers: ['topic_changer'],
|
|
319
|
-
};
|
|
320
|
-
},
|
|
321
|
-
],
|
|
322
|
-
},
|
|
323
|
-
],
|
|
324
|
-
writeHandler: (message) => {
|
|
325
|
-
writes.push(message.body);
|
|
326
|
-
},
|
|
327
|
-
promptHandler: async () => {
|
|
328
|
-
promptHitCount++;
|
|
329
|
-
if (promptHitCount > 2) {
|
|
330
|
-
await new Promise(() => { });
|
|
331
|
-
}
|
|
332
|
-
return 'go!';
|
|
333
|
-
},
|
|
334
|
-
selectPromptHandler: async () => '',
|
|
335
|
-
});
|
|
336
|
-
void tester.go();
|
|
337
|
-
await this.wait(500);
|
|
338
|
-
test_utils_1.assert.isEqual(promptHitCount, 3);
|
|
339
|
-
test_utils_1.assert.isEqualDeep(writes, [
|
|
340
|
-
'my',
|
|
341
|
-
'team',
|
|
342
|
-
'topic_changer',
|
|
343
|
-
(0, ScriptTester_1.generateTransitionMessage)('greeting'),
|
|
344
|
-
ScriptTester_1.END_OF_LINE,
|
|
345
|
-
'my',
|
|
346
|
-
'team',
|
|
347
|
-
'topic_changer',
|
|
348
|
-
(0, ScriptTester_1.generateTransitionMessage)('greeting'),
|
|
349
|
-
ScriptTester_1.END_OF_LINE,
|
|
350
|
-
]);
|
|
351
|
-
}
|
|
352
|
-
static async messagesAboutTransitionResponseWithRepairs() {
|
|
353
|
-
const writes = [];
|
|
354
|
-
let promptHitCount = 0;
|
|
355
|
-
const tester = await this.Tester({
|
|
356
|
-
lineDelay: 0,
|
|
357
|
-
topics: [
|
|
358
|
-
{
|
|
359
|
-
key: 'test',
|
|
360
|
-
label: 'Test with prompt',
|
|
361
|
-
utterances: [],
|
|
362
|
-
script: [
|
|
363
|
-
'my',
|
|
364
|
-
'team',
|
|
365
|
-
async () => {
|
|
366
|
-
return {
|
|
367
|
-
transitionConversationTo: 'greeting',
|
|
368
|
-
repairs: ['repairs'],
|
|
369
|
-
};
|
|
370
|
-
},
|
|
371
|
-
],
|
|
372
|
-
},
|
|
373
|
-
],
|
|
374
|
-
writeHandler: (message) => {
|
|
375
|
-
writes.push(message.body);
|
|
376
|
-
},
|
|
377
|
-
promptHandler: async () => {
|
|
378
|
-
promptHitCount++;
|
|
379
|
-
if (promptHitCount > 2) {
|
|
380
|
-
await new Promise(() => { });
|
|
381
|
-
}
|
|
382
|
-
return 'go!';
|
|
383
|
-
},
|
|
384
|
-
selectPromptHandler: async () => '',
|
|
385
|
-
});
|
|
386
|
-
void tester.go();
|
|
387
|
-
await this.wait(500);
|
|
388
|
-
test_utils_1.assert.isEqual(promptHitCount, 3);
|
|
389
|
-
test_utils_1.assert.isEqualDeep(writes, [
|
|
390
|
-
'my',
|
|
391
|
-
'team',
|
|
392
|
-
'repairs',
|
|
393
|
-
(0, ScriptTester_1.generateTransitionMessage)('greeting'),
|
|
394
|
-
ScriptTester_1.END_OF_LINE,
|
|
395
|
-
'my',
|
|
396
|
-
'team',
|
|
397
|
-
'repairs',
|
|
398
|
-
(0, ScriptTester_1.generateTransitionMessage)('greeting'),
|
|
399
|
-
ScriptTester_1.END_OF_LINE,
|
|
400
|
-
]);
|
|
401
|
-
}
|
|
402
|
-
static async Tester(options) {
|
|
403
|
-
return await ScriptTester_1.default.Tester(Object.assign({ getContext: () => ({}), topics: [] }, options));
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
ScriptTesterTest.basicBookingScript = [
|
|
407
|
-
{
|
|
408
|
-
utterances: [],
|
|
409
|
-
key: 'bookAppointment',
|
|
410
|
-
label: 'Book appointment',
|
|
411
|
-
script: ['you ready to book?'],
|
|
412
|
-
},
|
|
413
|
-
{
|
|
414
|
-
utterances: [],
|
|
415
|
-
key: 'cancelAppointment',
|
|
416
|
-
label: 'Cancel appointment',
|
|
417
|
-
script: ['Lets cancel'],
|
|
418
|
-
},
|
|
419
|
-
];
|
|
420
|
-
exports.default = ScriptTesterTest;
|
|
421
|
-
__decorate([
|
|
422
|
-
(0, test_utils_1.test)()
|
|
423
|
-
], ScriptTesterTest, "throwsWithoutScript", null);
|
|
424
|
-
__decorate([
|
|
425
|
-
(0, test_utils_1.test)()
|
|
426
|
-
], ScriptTesterTest, "acceptsSimpleScript", null);
|
|
427
|
-
__decorate([
|
|
428
|
-
(0, test_utils_1.test)()
|
|
429
|
-
], ScriptTesterTest, "callingGoDoesntCrash", null);
|
|
430
|
-
__decorate([
|
|
431
|
-
(0, test_utils_1.test)()
|
|
432
|
-
], ScriptTesterTest, "cantHandleMessageBeforeStartup", null);
|
|
433
|
-
__decorate([
|
|
434
|
-
(0, test_utils_1.test)()
|
|
435
|
-
], ScriptTesterTest, "selectingBadScriptToStartThrows", null);
|
|
436
|
-
__decorate([
|
|
437
|
-
(0, test_utils_1.test)()
|
|
438
|
-
], ScriptTesterTest, "asksWhichScriptYouWantToStartWithWhenThereIsMoreThanOne", null);
|
|
439
|
-
__decorate([
|
|
440
|
-
(0, test_utils_1.test)('plays single line script', ['hey there']),
|
|
441
|
-
(0, test_utils_1.test)('plays multi line script', ['hey there', 'how are you?'])
|
|
442
|
-
], ScriptTesterTest, "playsSimpleScript", null);
|
|
443
|
-
__decorate([
|
|
444
|
-
(0, test_utils_1.test)('passes the confirm', 'yes'),
|
|
445
|
-
(0, test_utils_1.test)('fails the confirm', 'no')
|
|
446
|
-
], ScriptTesterTest, "canSendInputToThePlayer", null);
|
|
447
|
-
__decorate([
|
|
448
|
-
(0, test_utils_1.test)()
|
|
449
|
-
], ScriptTesterTest, "promptsForFirstMessageIfNoneSentToGo", null);
|
|
450
|
-
__decorate([
|
|
451
|
-
(0, test_utils_1.test)()
|
|
452
|
-
], ScriptTesterTest, "showsConfidenceRatingBasedOnFirstMesageSent", null);
|
|
453
|
-
__decorate([
|
|
454
|
-
(0, test_utils_1.test)()
|
|
455
|
-
], ScriptTesterTest, "promptsToStartAgainAfterDone", null);
|
|
456
|
-
__decorate([
|
|
457
|
-
(0, test_utils_1.test)()
|
|
458
|
-
], ScriptTesterTest, "messagesAboutTransitionResponseTopicChanger", null);
|
|
459
|
-
__decorate([
|
|
460
|
-
(0, test_utils_1.test)()
|
|
461
|
-
], ScriptTesterTest, "messagesAboutTransitionResponseWithRepairs", null);
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import AbstractConversationTest from '../../tests/AbstractConversationTest';
|
|
2
|
-
export default class SuggesterUtilTest extends AbstractConversationTest {
|
|
3
|
-
protected static suggesterExists(): Promise<void>;
|
|
4
|
-
protected static returnsOnlyPossibility(): Promise<void>;
|
|
5
|
-
protected static returnsSortedByBestGuess(): Promise<void>;
|
|
6
|
-
protected static matchesByReturningTopOptionsAboveThreshold(phrases: string[], utterance: string, expected: boolean): Promise<void>;
|
|
7
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
13
|
-
const AbstractConversationTest_1 = __importDefault(require("../../tests/AbstractConversationTest"));
|
|
14
|
-
const suggester_utility_1 = __importDefault(require("../../utilities/suggester.utility"));
|
|
15
|
-
class SuggesterUtilTest extends AbstractConversationTest_1.default {
|
|
16
|
-
static async suggesterExists() {
|
|
17
|
-
test_utils_1.assert.isTruthy(suggester_utility_1.default);
|
|
18
|
-
}
|
|
19
|
-
static async returnsOnlyPossibility() {
|
|
20
|
-
const results = await suggester_utility_1.default.rank([{ key: 'test', phrase: 'test' }], 'test');
|
|
21
|
-
test_utils_1.assert.isArray(results);
|
|
22
|
-
test_utils_1.assert.isEqualDeep(results, [
|
|
23
|
-
{
|
|
24
|
-
key: 'test',
|
|
25
|
-
score: 1,
|
|
26
|
-
},
|
|
27
|
-
]);
|
|
28
|
-
}
|
|
29
|
-
static async returnsSortedByBestGuess() {
|
|
30
|
-
const results = await suggester_utility_1.default.rank([
|
|
31
|
-
{ key: 'wronge', phrase: 'wronge' },
|
|
32
|
-
{ key: 'test', phrase: 'test' },
|
|
33
|
-
], 'test');
|
|
34
|
-
test_utils_1.assert.isArray(results);
|
|
35
|
-
test_utils_1.assert.isEqualDeep(results[0], {
|
|
36
|
-
key: 'test',
|
|
37
|
-
score: 1,
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
static async matchesByReturningTopOptionsAboveThreshold(phrases, utterance, expected) {
|
|
41
|
-
const results = await suggester_utility_1.default.doesMatch(phrases, utterance);
|
|
42
|
-
test_utils_1.assert.isEqual(results, expected);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
exports.default = SuggesterUtilTest;
|
|
46
|
-
__decorate([
|
|
47
|
-
(0, test_utils_1.test)()
|
|
48
|
-
], SuggesterUtilTest, "suggesterExists", null);
|
|
49
|
-
__decorate([
|
|
50
|
-
(0, test_utils_1.test)()
|
|
51
|
-
], SuggesterUtilTest, "returnsOnlyPossibility", null);
|
|
52
|
-
__decorate([
|
|
53
|
-
(0, test_utils_1.test)()
|
|
54
|
-
], SuggesterUtilTest, "returnsSortedByBestGuess", null);
|
|
55
|
-
__decorate([
|
|
56
|
-
(0, test_utils_1.test)('doesMatch is false when way off', ['one', 'two', 'three', 'four'], 'miss', false),
|
|
57
|
-
(0, test_utils_1.test)('doesMatch is true when perfect match', ['one', 'two', 'three', 'four'], 'one', true),
|
|
58
|
-
(0, test_utils_1.test)('doesMatch is true with ha', ['ha', 'haha', 'lol', 'lolz', 'rofl', 'hahahah', 'haha'], 'haha!!!', true),
|
|
59
|
-
(0, test_utils_1.test)('doesMatch is true with ha', ['ha', 'haha', 'lol', 'lolz', 'rofl', 'hahahah'], 'lol', true),
|
|
60
|
-
(0, test_utils_1.test)('doesMatch is false with lame', ['ha', 'haha', 'lol', 'lolz', 'rofl', 'hahahah'], 'lame', false),
|
|
61
|
-
(0, test_utils_1.test)('doesMatch is false with horrible', ['ha', 'haha', 'lol', 'lolz', 'rofl', 'hahahah'], 'horrible', false),
|
|
62
|
-
(0, test_utils_1.test)('doesMatch is false with hey', ['ha', 'haha', 'lol', 'lolz', 'rofl', 'hahahah'], 'hey', false)
|
|
63
|
-
], SuggesterUtilTest, "matchesByReturningTopOptionsAboveThreshold", null);
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import AbstractConversationTest from '../../tests/AbstractConversationTest';
|
|
2
|
-
export default class TopicLoaderTest extends AbstractConversationTest {
|
|
3
|
-
protected static loadsNoTopicsWithBadDir(): Promise<void>;
|
|
4
|
-
protected static throwsWhenLoadingEmpty(): Promise<void>;
|
|
5
|
-
protected static throwsWhenMissingParameters(): Promise<void>;
|
|
6
|
-
protected static canLoadTopics(): Promise<void>;
|
|
7
|
-
protected static loadedTopicsSetKey(): Promise<void>;
|
|
8
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
13
|
-
const test_utils_2 = require("@sprucelabs/test-utils");
|
|
14
|
-
const AbstractConversationTest_1 = __importDefault(require("../../tests/AbstractConversationTest"));
|
|
15
|
-
const TopicLoader_1 = __importDefault(require("../../topics/TopicLoader"));
|
|
16
|
-
class TopicLoaderTest extends AbstractConversationTest_1.default {
|
|
17
|
-
static async loadsNoTopicsWithBadDir() {
|
|
18
|
-
const source = this.resolvePath('doesNotExist');
|
|
19
|
-
const topics = await TopicLoader_1.default.loadTopics(source);
|
|
20
|
-
test_utils_1.assert.isLength(topics, 0);
|
|
21
|
-
}
|
|
22
|
-
static async throwsWhenLoadingEmpty() {
|
|
23
|
-
const source = this.resolveTestPath('bad-empty');
|
|
24
|
-
const err = await test_utils_1.assert.doesThrowAsync(() => TopicLoader_1.default.loadTopics(source));
|
|
25
|
-
test_utils_2.errorAssert.assertError(err, 'INVALID_TOPIC', {
|
|
26
|
-
topicScript: 'bookAppointment.topic',
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
static async throwsWhenMissingParameters() {
|
|
30
|
-
const source = this.resolveTestPath('bad-missing-params');
|
|
31
|
-
const err = await test_utils_1.assert.doesThrowAsync(() => TopicLoader_1.default.loadTopics(source));
|
|
32
|
-
test_utils_2.errorAssert.assertError(err, 'INVALID_TOPIC', {
|
|
33
|
-
topicScript: 'bookAppointment.topic',
|
|
34
|
-
});
|
|
35
|
-
//@ts-ignore
|
|
36
|
-
const original = err.options.originalError;
|
|
37
|
-
test_utils_2.errorAssert.assertError(original, 'MISSING_PARAMETERS', {
|
|
38
|
-
parameters: ['label', 'utterances', 'script'],
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
static async canLoadTopics() {
|
|
42
|
-
const scripts = await TopicLoader_1.default.loadTopics(this.resolveTestPath('good'));
|
|
43
|
-
test_utils_1.assert.isLength(scripts, 2);
|
|
44
|
-
}
|
|
45
|
-
static async loadedTopicsSetKey() {
|
|
46
|
-
const scripts = await TopicLoader_1.default.loadTopics(this.resolveTestPath('good'));
|
|
47
|
-
test_utils_1.assert.doesInclude(scripts, { key: 'bookAppointment' });
|
|
48
|
-
test_utils_1.assert.doesInclude(scripts, { key: 'cancelAppointment' });
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
exports.default = TopicLoaderTest;
|
|
52
|
-
__decorate([
|
|
53
|
-
(0, test_utils_1.test)()
|
|
54
|
-
], TopicLoaderTest, "loadsNoTopicsWithBadDir", null);
|
|
55
|
-
__decorate([
|
|
56
|
-
(0, test_utils_1.test)()
|
|
57
|
-
], TopicLoaderTest, "throwsWhenLoadingEmpty", null);
|
|
58
|
-
__decorate([
|
|
59
|
-
(0, test_utils_1.test)()
|
|
60
|
-
], TopicLoaderTest, "throwsWhenMissingParameters", null);
|
|
61
|
-
__decorate([
|
|
62
|
-
(0, test_utils_1.test)()
|
|
63
|
-
], TopicLoaderTest, "canLoadTopics", null);
|
|
64
|
-
__decorate([
|
|
65
|
-
(0, test_utils_1.test)()
|
|
66
|
-
], TopicLoaderTest, "loadedTopicsSetKey", null);
|