@sprucelabs/spruce-conversation-plugin 45.2.7 → 46.0.0

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.
Files changed (123) hide show
  1. package/build/__tests__/behavioral/CheckingHealth.test.d.ts +10 -0
  2. package/build/__tests__/behavioral/CheckingHealth.test.js +87 -0
  3. package/build/__tests__/behavioral/KillingASkill.test.d.ts +4 -0
  4. package/build/__tests__/behavioral/KillingASkill.test.js +27 -0
  5. package/build/__tests__/behavioral/RegisteringConversationsOnBoot.test.d.ts +11 -0
  6. package/build/__tests__/behavioral/RegisteringConversationsOnBoot.test.js +106 -0
  7. package/build/__tests__/behavioral/RespondingToMessages.test.d.ts +13 -0
  8. package/build/__tests__/behavioral/RespondingToMessages.test.js +139 -0
  9. package/build/__tests__/behavioral/TestingAConversation.test.d.ts +10 -0
  10. package/build/__tests__/behavioral/TestingAConversation.test.js +70 -0
  11. package/build/__tests__/implementation/ConversationCoordinator.test.d.ts +15 -0
  12. package/build/__tests__/implementation/ConversationCoordinator.test.js +142 -0
  13. package/build/__tests__/implementation/MessageGraphicsInterface/EmailField.test.d.ts +7 -0
  14. package/build/__tests__/implementation/MessageGraphicsInterface/EmailField.test.js +71 -0
  15. package/build/__tests__/implementation/MessageGraphicsInterface/MessageGraphicsInterface.test.d.ts +4 -0
  16. package/build/__tests__/implementation/MessageGraphicsInterface/MessageGraphicsInterface.test.js +42 -0
  17. package/build/__tests__/implementation/MessageGraphicsInterface/SelectField.test.d.ts +7 -0
  18. package/build/__tests__/implementation/MessageGraphicsInterface/SelectField.test.js +71 -0
  19. package/build/__tests__/implementation/MessageGraphicsInterface/TextField.test.d.ts +6 -0
  20. package/build/__tests__/implementation/MessageGraphicsInterface/TextField.test.js +46 -0
  21. package/build/__tests__/implementation/ScriptTester.test.d.ts +18 -0
  22. package/build/__tests__/implementation/ScriptTester.test.js +459 -0
  23. package/build/__tests__/implementation/SuggesterUtil.test.d.ts +7 -0
  24. package/build/__tests__/implementation/SuggesterUtil.test.js +63 -0
  25. package/build/__tests__/implementation/TopicLoader.test.d.ts +8 -0
  26. package/build/__tests__/implementation/TopicLoader.test.js +66 -0
  27. package/build/__tests__/implementation/TopicScriptPlayer.test.d.ts +21 -0
  28. package/build/__tests__/implementation/TopicScriptPlayer.test.js +413 -0
  29. package/build/__tests__/implementation/TopicSuggester.test.d.ts +8 -0
  30. package/build/__tests__/implementation/TopicSuggester.test.js +131 -0
  31. package/build/__tests__/testDirsAndFiles/bad-empty/conversations/bookAppointment.topic.d.ts +0 -0
  32. package/build/__tests__/testDirsAndFiles/bad-empty/conversations/bookAppointment.topic.js +1 -0
  33. package/build/__tests__/testDirsAndFiles/bad-missing-params/conversations/bookAppointment.topic.d.ts +2 -0
  34. package/build/__tests__/testDirsAndFiles/bad-missing-params/conversations/bookAppointment.topic.js +4 -0
  35. package/build/__tests__/testDirsAndFiles/bad-skill/build/.spruce/events/listeners.d.ts +2 -0
  36. package/build/__tests__/testDirsAndFiles/bad-skill/build/.spruce/events/listeners.js +3 -0
  37. package/build/__tests__/testDirsAndFiles/bad-skill/build/conversations/bookAppointment.topic.d.ts +2 -0
  38. package/build/__tests__/testDirsAndFiles/bad-skill/build/conversations/bookAppointment.topic.js +4 -0
  39. package/build/__tests__/testDirsAndFiles/empty-skill/build/.spruce/events/listeners.d.ts +2 -0
  40. package/build/__tests__/testDirsAndFiles/empty-skill/build/.spruce/events/listeners.js +3 -0
  41. package/build/__tests__/testDirsAndFiles/good/conversations/bookAppointment.topic.d.ts +3 -0
  42. package/build/__tests__/testDirsAndFiles/good/conversations/bookAppointment.topic.js +8 -0
  43. package/build/__tests__/testDirsAndFiles/good/conversations/cancelAppointment.topic.d.ts +3 -0
  44. package/build/__tests__/testDirsAndFiles/good/conversations/cancelAppointment.topic.js +8 -0
  45. package/build/__tests__/testDirsAndFiles/skill/build/.spruce/events/listeners.d.ts +2 -0
  46. package/build/__tests__/testDirsAndFiles/skill/build/.spruce/events/listeners.js +3 -0
  47. package/build/__tests__/testDirsAndFiles/skill/build/conversations/bookAppointment.topic.d.ts +3 -0
  48. package/build/__tests__/testDirsAndFiles/skill/build/conversations/bookAppointment.topic.js +8 -0
  49. package/build/__tests__/testDirsAndFiles/skill/build/conversations/cancelAppointment.topic.d.ts +3 -0
  50. package/build/__tests__/testDirsAndFiles/skill/build/conversations/cancelAppointment.topic.js +8 -0
  51. package/build/__tests__/testDirsAndFiles/skill/build/conversations/favoriteColor.topic.d.ts +3 -0
  52. package/build/__tests__/testDirsAndFiles/skill/build/conversations/favoriteColor.topic.js +18 -0
  53. package/build/__tests__/testDirsAndFiles/skill/build/conversations/favoriteColorTopicChanger.topic.d.ts +3 -0
  54. package/build/__tests__/testDirsAndFiles/skill/build/conversations/favoriteColorTopicChanger.topic.js +18 -0
  55. package/build/__tests__/testDirsAndFiles/skill/build/conversations/mixedStringsAndCallbacks.topic.d.ts +3 -0
  56. package/build/__tests__/testDirsAndFiles/skill/build/conversations/mixedStringsAndCallbacks.topic.js +29 -0
  57. package/build/__tests__/testDirsAndFiles/skill-assertions/build/.spruce/events/listeners.d.ts +2 -0
  58. package/build/__tests__/testDirsAndFiles/skill-assertions/build/.spruce/events/listeners.js +3 -0
  59. package/build/__tests__/testDirsAndFiles/skill-assertions/build/conversations/assertsScriptCallbackOptions.topic.d.ts +3 -0
  60. package/build/__tests__/testDirsAndFiles/skill-assertions/build/conversations/assertsScriptCallbackOptions.topic.js +22 -0
  61. package/build/__tests__/testDirsAndFiles/skill-assertions/build/conversations/assertsScriptOnlyCalledOnce.topic.d.ts +3 -0
  62. package/build/__tests__/testDirsAndFiles/skill-assertions/build/conversations/assertsScriptOnlyCalledOnce.topic.js +14 -0
  63. package/build/__tests__/testDirsAndFiles/skill-with-script-that-throws/build/.spruce/events/listeners.d.ts +2 -0
  64. package/build/__tests__/testDirsAndFiles/skill-with-script-that-throws/build/.spruce/events/listeners.js +3 -0
  65. package/build/__tests__/testDirsAndFiles/skill-with-script-that-throws/build/conversations/cancelAppointment.topic.d.ts +3 -0
  66. package/build/__tests__/testDirsAndFiles/skill-with-script-that-throws/build/conversations/cancelAppointment.topic.js +12 -0
  67. package/build/esm/__tests__/behavioral/CheckingHealth.test.d.ts +10 -0
  68. package/build/esm/__tests__/behavioral/CheckingHealth.test.js +104 -0
  69. package/build/esm/__tests__/behavioral/KillingASkill.test.d.ts +4 -0
  70. package/build/esm/__tests__/behavioral/KillingASkill.test.js +32 -0
  71. package/build/esm/__tests__/behavioral/RegisteringConversationsOnBoot.test.d.ts +11 -0
  72. package/build/esm/__tests__/behavioral/RegisteringConversationsOnBoot.test.js +126 -0
  73. package/build/esm/__tests__/behavioral/RespondingToMessages.test.d.ts +13 -0
  74. package/build/esm/__tests__/behavioral/RespondingToMessages.test.js +156 -0
  75. package/build/esm/__tests__/behavioral/TestingAConversation.test.d.ts +10 -0
  76. package/build/esm/__tests__/behavioral/TestingAConversation.test.js +93 -0
  77. package/build/esm/__tests__/implementation/ConversationCoordinator.test.d.ts +15 -0
  78. package/build/esm/__tests__/implementation/ConversationCoordinator.test.js +168 -0
  79. package/build/esm/__tests__/implementation/MessageGraphicsInterface/EmailField.test.d.ts +7 -0
  80. package/build/esm/__tests__/implementation/MessageGraphicsInterface/EmailField.test.js +82 -0
  81. package/build/esm/__tests__/implementation/MessageGraphicsInterface/MessageGraphicsInterface.test.d.ts +4 -0
  82. package/build/esm/__tests__/implementation/MessageGraphicsInterface/MessageGraphicsInterface.test.js +47 -0
  83. package/build/esm/__tests__/implementation/MessageGraphicsInterface/SelectField.test.d.ts +7 -0
  84. package/build/esm/__tests__/implementation/MessageGraphicsInterface/SelectField.test.js +80 -0
  85. package/build/esm/__tests__/implementation/MessageGraphicsInterface/TextField.test.d.ts +6 -0
  86. package/build/esm/__tests__/implementation/MessageGraphicsInterface/TextField.test.js +55 -0
  87. package/build/esm/__tests__/implementation/ScriptTester.test.d.ts +18 -0
  88. package/build/esm/__tests__/implementation/ScriptTester.test.js +465 -0
  89. package/build/esm/__tests__/implementation/SuggesterUtil.test.d.ts +7 -0
  90. package/build/esm/__tests__/implementation/SuggesterUtil.test.js +74 -0
  91. package/build/esm/__tests__/implementation/TopicLoader.test.d.ts +8 -0
  92. package/build/esm/__tests__/implementation/TopicLoader.test.js +79 -0
  93. package/build/esm/__tests__/implementation/TopicScriptPlayer.test.d.ts +21 -0
  94. package/build/esm/__tests__/implementation/TopicScriptPlayer.test.js +452 -0
  95. package/build/esm/__tests__/implementation/TopicSuggester.test.d.ts +8 -0
  96. package/build/esm/__tests__/implementation/TopicSuggester.test.js +124 -0
  97. package/build/esm/__tests__/testDirsAndFiles/bad-empty/conversations/bookAppointment.topic.d.ts +0 -0
  98. package/build/esm/__tests__/testDirsAndFiles/bad-empty/conversations/bookAppointment.topic.js +1 -0
  99. package/build/esm/__tests__/testDirsAndFiles/bad-missing-params/conversations/bookAppointment.topic.d.ts +2 -0
  100. package/build/esm/__tests__/testDirsAndFiles/bad-missing-params/conversations/bookAppointment.topic.js +2 -0
  101. package/build/esm/__tests__/testDirsAndFiles/bad-skill/build/conversations/bookAppointment.topic.d.ts +2 -0
  102. package/build/esm/__tests__/testDirsAndFiles/bad-skill/build/conversations/bookAppointment.topic.js +2 -0
  103. package/build/esm/__tests__/testDirsAndFiles/good/conversations/bookAppointment.topic.d.ts +3 -0
  104. package/build/esm/__tests__/testDirsAndFiles/good/conversations/bookAppointment.topic.js +6 -0
  105. package/build/esm/__tests__/testDirsAndFiles/good/conversations/cancelAppointment.topic.d.ts +3 -0
  106. package/build/esm/__tests__/testDirsAndFiles/good/conversations/cancelAppointment.topic.js +6 -0
  107. package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/bookAppointment.topic.d.ts +3 -0
  108. package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/bookAppointment.topic.js +6 -0
  109. package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/cancelAppointment.topic.d.ts +3 -0
  110. package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/cancelAppointment.topic.js +6 -0
  111. package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/favoriteColor.topic.d.ts +3 -0
  112. package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/favoriteColor.topic.js +25 -0
  113. package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/favoriteColorTopicChanger.topic.d.ts +3 -0
  114. package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/favoriteColorTopicChanger.topic.js +25 -0
  115. package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/mixedStringsAndCallbacks.topic.d.ts +3 -0
  116. package/build/esm/__tests__/testDirsAndFiles/skill/build/conversations/mixedStringsAndCallbacks.topic.js +36 -0
  117. package/build/esm/__tests__/testDirsAndFiles/skill-assertions/build/conversations/assertsScriptCallbackOptions.topic.d.ts +3 -0
  118. package/build/esm/__tests__/testDirsAndFiles/skill-assertions/build/conversations/assertsScriptCallbackOptions.topic.js +29 -0
  119. package/build/esm/__tests__/testDirsAndFiles/skill-assertions/build/conversations/assertsScriptOnlyCalledOnce.topic.d.ts +3 -0
  120. package/build/esm/__tests__/testDirsAndFiles/skill-assertions/build/conversations/assertsScriptOnlyCalledOnce.topic.js +21 -0
  121. package/build/esm/__tests__/testDirsAndFiles/skill-with-script-that-throws/build/conversations/cancelAppointment.topic.d.ts +3 -0
  122. package/build/esm/__tests__/testDirsAndFiles/skill-with-script-that-throws/build/conversations/cancelAppointment.topic.js +10 -0
  123. package/package.json +10 -10
@@ -0,0 +1,71 @@
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_1 = require("@sprucelabs/test");
13
+ const EmailFieldHandler_1 = __importDefault(require("../../../interfaces/fieldHandlers/EmailFieldHandler"));
14
+ const AbstractGraphicsInterfaceTest_1 = __importDefault(require("../../../tests/AbstractGraphicsInterfaceTest"));
15
+ class TextFieldTest extends AbstractGraphicsInterfaceTest_1.default {
16
+ static async promptSendsLabel() {
17
+ void this.ui.prompt({
18
+ type: 'email',
19
+ label: 'Tell me about your life.',
20
+ });
21
+ test_1.assert.doesInclude(this.sentMessages, { body: 'Tell me about your life.' });
22
+ }
23
+ static async noPromptSendsNoMessage() {
24
+ void this.ui.prompt({
25
+ type: 'email',
26
+ });
27
+ test_1.assert.isLength(this.sentMessages, 0);
28
+ }
29
+ static async respondingWithBadEmailGivesYouAnotherChance() {
30
+ EmailFieldHandler_1.default.repairs = ['repair', 'repair'];
31
+ let wasHit = false;
32
+ void this.ui
33
+ .prompt({
34
+ type: 'email',
35
+ label: 'What is your email?',
36
+ })
37
+ .then(() => {
38
+ wasHit = true;
39
+ });
40
+ test_1.assert.isLength(this.sentMessages, 1);
41
+ test_1.assert.doesInclude(this.sentMessages, { body: 'What is your email?' });
42
+ await this.sendMessage('aoeuaoeu');
43
+ test_1.assert.isLength(this.sentMessages, 2);
44
+ test_1.assert.doesInclude(this.sentMessages, { body: 'repair' });
45
+ test_1.assert.isFalse(wasHit);
46
+ }
47
+ static async respondingWithBadEmail2TimesErrors() {
48
+ const promise = this.ui.prompt({
49
+ type: 'email',
50
+ label: 'What is your email?',
51
+ });
52
+ test_1.assert.isLength(this.sentMessages, 1);
53
+ test_1.assert.doesInclude(this.sentMessages, { body: 'What is your email?' });
54
+ await this.sendMessage('aoeuaoeu');
55
+ await this.sendMessage('aoeuaoeu');
56
+ await test_1.assert.doesThrowAsync(() => promise);
57
+ }
58
+ }
59
+ __decorate([
60
+ (0, test_1.test)()
61
+ ], TextFieldTest, "promptSendsLabel", null);
62
+ __decorate([
63
+ (0, test_1.test)()
64
+ ], TextFieldTest, "noPromptSendsNoMessage", null);
65
+ __decorate([
66
+ (0, test_1.test)()
67
+ ], TextFieldTest, "respondingWithBadEmailGivesYouAnotherChance", null);
68
+ __decorate([
69
+ (0, test_1.test)()
70
+ ], TextFieldTest, "respondingWithBadEmail2TimesErrors", null);
71
+ exports.default = TextFieldTest;
@@ -0,0 +1,4 @@
1
+ import AbstractGraphicsInterfaceTest from '../../../tests/AbstractGraphicsInterfaceTest';
2
+ export default class MessageGraphicsInterfaceTest extends AbstractGraphicsInterfaceTest {
3
+ protected static selectAsksAgainWithBadResponse(): Promise<void>;
4
+ }
@@ -0,0 +1,42 @@
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_1 = require("@sprucelabs/test");
13
+ const test_utils_1 = require("@sprucelabs/test-utils");
14
+ const AbstractGraphicsInterfaceTest_1 = __importDefault(require("../../../tests/AbstractGraphicsInterfaceTest"));
15
+ class MessageGraphicsInterfaceTest extends AbstractGraphicsInterfaceTest_1.default {
16
+ static async selectAsksAgainWithBadResponse() {
17
+ const promise = this.ui.prompt({
18
+ type: 'select',
19
+ label: 'What would you like to do?',
20
+ isRequired: true,
21
+ options: {
22
+ choices: [
23
+ {
24
+ label: 'Book appointment',
25
+ value: 'bookAppointment',
26
+ },
27
+ {
28
+ label: 'Cancel appointment',
29
+ value: 'cancelAppointment',
30
+ },
31
+ ],
32
+ },
33
+ });
34
+ await this.sendMessage('get me out of here!');
35
+ const err = await test_1.assert.doesThrowAsync(async () => await promise);
36
+ test_utils_1.errorAssert.assertError(err, 'ABORT');
37
+ }
38
+ }
39
+ __decorate([
40
+ (0, test_1.test)()
41
+ ], MessageGraphicsInterfaceTest, "selectAsksAgainWithBadResponse", null);
42
+ exports.default = MessageGraphicsInterfaceTest;
@@ -0,0 +1,7 @@
1
+ import AbstractGraphicsInterfaceTest from '../../../tests/AbstractGraphicsInterfaceTest';
2
+ export default class MessageGraphicsInterfaceTest extends AbstractGraphicsInterfaceTest {
3
+ protected static respondingWithNumberSelectsOptions(): Promise<void>;
4
+ protected static respondingWithBadNumberAsksYouToSelectAgain(): Promise<void>;
5
+ protected static respondingWithCloseMatchSelectsChoice(): Promise<void>;
6
+ private static renderAppointmentSelect;
7
+ }
@@ -0,0 +1,71 @@
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_1 = require("@sprucelabs/test");
13
+ const AbstractGraphicsInterfaceTest_1 = __importDefault(require("../../../tests/AbstractGraphicsInterfaceTest"));
14
+ class MessageGraphicsInterfaceTest extends AbstractGraphicsInterfaceTest_1.default {
15
+ static async respondingWithNumberSelectsOptions() {
16
+ const promise = this.renderAppointmentSelect();
17
+ await this.sendMessage('1');
18
+ const results = await promise;
19
+ test_1.assert.isEqual(results, 'bookAppointment');
20
+ }
21
+ static async respondingWithBadNumberAsksYouToSelectAgain() {
22
+ void this.renderAppointmentSelect();
23
+ await this.sendMessage('5');
24
+ await this.sendMessage('5');
25
+ test_1.assert.doesInclude(this.sentMessages, { body: 'invalid-value-repair' });
26
+ test_1.assert.doesInclude(this.sentMessages, { body: 'invalid-value-repair2' });
27
+ const last = this.sentMessages.pop();
28
+ test_1.assert.isTruthy(last === null || last === void 0 ? void 0 : last.choices);
29
+ }
30
+ static async respondingWithCloseMatchSelectsChoice() {
31
+ const promise = this.renderAppointmentSelect();
32
+ await this.sendMessage('book please');
33
+ const selection = await promise;
34
+ test_1.assert.isEqual(selection, 'bookAppointment');
35
+ }
36
+ static renderAppointmentSelect() {
37
+ const choices = [
38
+ {
39
+ label: 'Book appointment',
40
+ value: 'bookAppointment',
41
+ },
42
+ {
43
+ label: 'Cancel appointment',
44
+ value: 'cancelAppointment',
45
+ },
46
+ ];
47
+ const response = this.ui.prompt({
48
+ type: 'select',
49
+ label: 'What would you like to do?',
50
+ isRequired: true,
51
+ options: {
52
+ choices,
53
+ },
54
+ });
55
+ test_1.assert.doesInclude(this.sentMessages, {
56
+ body: 'What would you like to do?',
57
+ choices,
58
+ });
59
+ return response;
60
+ }
61
+ }
62
+ __decorate([
63
+ (0, test_1.test)()
64
+ ], MessageGraphicsInterfaceTest, "respondingWithNumberSelectsOptions", null);
65
+ __decorate([
66
+ (0, test_1.test)()
67
+ ], MessageGraphicsInterfaceTest, "respondingWithBadNumberAsksYouToSelectAgain", null);
68
+ __decorate([
69
+ (0, test_1.test)()
70
+ ], MessageGraphicsInterfaceTest, "respondingWithCloseMatchSelectsChoice", null);
71
+ exports.default = MessageGraphicsInterfaceTest;
@@ -0,0 +1,6 @@
1
+ import AbstractGraphicsInterfaceTest from '../../../tests/AbstractGraphicsInterfaceTest';
2
+ export default class TextFieldTest extends AbstractGraphicsInterfaceTest {
3
+ protected static promptSendsLabel(): Promise<void>;
4
+ protected static noPromptSendsNoMessage(): Promise<void>;
5
+ protected static canRespondToPrompt(): Promise<void>;
6
+ }
@@ -0,0 +1,46 @@
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_1 = require("@sprucelabs/test");
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_1.assert.doesInclude(this.sentMessages, { body: 'Tell me about your life.' });
21
+ }
22
+ static async noPromptSendsNoMessage() {
23
+ void this.ui.prompt({
24
+ type: 'text',
25
+ });
26
+ test_1.assert.isLength(this.sentMessages, 0);
27
+ }
28
+ static async canRespondToPrompt() {
29
+ const promise = this.ui.prompt({
30
+ type: 'text',
31
+ });
32
+ await this.sendMessage('hey there!');
33
+ const answer = await promise;
34
+ test_1.assert.isEqual(answer, 'hey there!');
35
+ }
36
+ }
37
+ __decorate([
38
+ (0, test_1.test)()
39
+ ], TextFieldTest, "promptSendsLabel", null);
40
+ __decorate([
41
+ (0, test_1.test)()
42
+ ], TextFieldTest, "noPromptSendsNoMessage", null);
43
+ __decorate([
44
+ (0, test_1.test)()
45
+ ], TextFieldTest, "canRespondToPrompt", null);
46
+ exports.default = TextFieldTest;
@@ -0,0 +1,18 @@
1
+ import AbstractConversationTest from '../../tests/AbstractConversationTest';
2
+ import { Script } from '../../types/conversation.types';
3
+ export default class ScriptTesterTest extends AbstractConversationTest {
4
+ protected static throwsWithoutScript(): Promise<void>;
5
+ protected static acceptsSimpleScript(): Promise<void>;
6
+ protected static callingGoDoesntCrash(): Promise<void>;
7
+ protected static cantHandleMessageBeforeStartup(): Promise<void>;
8
+ protected static selectingBadScriptToStartThrows(): Promise<void>;
9
+ private static readonly basicBookingScript;
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
+ }