/
types.ts
137 lines (118 loc) · 5.41 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*
* Copyright (c) 2018. Taimos GmbH http://www.taimos.de
*/
import { RequestEnvelope, ResponseEnvelope } from 'ask-sdk-model';
export interface SkillSettings {
/** The skill id */
appId : string;
/** The user id to simulate */
userId : string;
/** The device id to simulate */
deviceId : string;
/** the locale to use when generating requests */
locale : string;
/** the interfaces present for the test */
interfaces? : InterfaceSettings;
/** true to print the response to the console */
debug? : boolean;
}
export interface InterfaceSettings {
display? : boolean;
audio? : boolean;
video? : boolean;
apl? : boolean;
}
export interface SequenceItem {
/** The request to run. Generate these with one of the above `getFooRequest` methods. */
request : RequestEnvelope;
/** Receives the response object from the request as a parameter. You can make custom checks against the response using any assertion library you like in here. */
callback? : (response : ResponseEnvelope) => void;
/** Tests that the speech output from the request is the string specified. */
says? : string | string[] | ((speech : string) => boolean);
/** Tests that the speech output from the request contains the string specified. */
saysLike? : string;
/** If true, tests that the response has no speech output. */
saysNothing? : boolean;
/** Tests that the reprompt output from the request is the string specified. */
reprompts? : string | string[] | ((speech : string) => boolean);
/** Tests that the reprompt output from the request contains the string specified. */
repromptsLike? : string;
/** If true, tests that the response has no reprompt output. */
repromptsNothing? : boolean;
/** If true, tests that the response to the request ends or does not end the session. */
shouldEndSession? : boolean;
/** If true, tests that the response speech contains a question mark when the session is kept open */
ignoreQuestionCheck? : boolean;
/** Tests that the response asks Alexa to elicit the given slot. */
elicitsSlot? : string;
/** Tests that the response asks Alexa to elicit the a slot of the given intent. */
elicitsForIntent? : string;
/** Tests that the response asks Alexa to confirm the given slot. */
confirmsSlot? : string;
/** Tests that the response asks Alexa to confirm the intent. */
confirmsIntent? : boolean;
/** Tests that the response contains the given attributes and values. Values can be strings, numbers, booleans or functions testing the value. */
hasAttributes? : { [key : string] : (string | number | boolean | ((attribute : any) => boolean)) };
/** The session attributes to initialize the intent request with. */
withSessionAttributes? : { [key : string] : any };
/** Tests that the given attributes were stored in the DynamoDB. Values can be strings, numbers, booleans or functions testing the value. */
storesAttributes? : { [key : string] : (string | number | boolean | ((attribute : any) => boolean)) };
/** The attributes to initialize the handler with. Used with DynamoDB mock. */
withStoredAttributes? : { [key : string] : any };
/** Tests that the card sent by the response has the title specified. */
hasCardTitle? : string;
/** Tests that the card sent by the response is a simple card and has the content specified. */
hasCardContent? : string;
/** Tests that the card sent by the response is a simple card and contains the content specified. */
hasCardContentLike? : string;
/** Tests that the card sent by the response is a standard card and has the text specified. */
hasCardText? : string;
/** Tests that the card sent by the response is a standard card and contains the text specified. */
hasCardTextLike? : string;
/** Tests that the card sent by the response is a standard card and has a small image URL containing the string specified. */
hasSmallImageUrlLike? : string;
/** Tests that the card sent by the response is a standard card and has a large image URL containing the string specified. */
hasLargeImageUrlLike? : string;
/** Tests that the AudioPlayer is used to play a stream. */
playsStream? : PlayStreamConfig;
/** Tests that the AudioPlayer is stopped. */
stopsStream? : boolean;
/** Tests that the AudioPlayer clears the queue with the given clear behavior. */
clearsQueue? : string;
/** Tests that the VideoPlayer is used to play a stream. */
playsVideo? : PlayVideoConfig;
/** Tests that the RenderDirective is used to . */
renderDocument? : RenderDocumentConfig;
/** The profile information for API calls. Ups will be unauthorized when this is undefined */
withProfile? : ProfileInfo;
/** The accessToken to provide for account linking */
withUserAccessToken? : string;
/** Any additional fields for custom validators */
[key : string] : any;
}
export interface RenderDocumentConfig {
token? : string;
document? : (document : any) => boolean;
hasDataSources? : { [key : string] : (datasource : any) => boolean };
}
export interface PlayStreamConfig {
behavior? : string;
token? : string;
previousToken? : string;
url? : string;
offset? : number;
}
export interface PlayVideoConfig {
source? : string;
titel? : string;
subtitle? : string;
}
export interface ProfileInfo {
name? : string;
givenName? : string;
email? : string;
mobileNumber? : string;
}
export abstract class ResponseValidator {
public abstract validate(currentItem : SequenceItem, response : ResponseEnvelope) : void;
}