@@ -8,10 +8,15 @@ import {expect} from 'expect';
8
8
9
9
interface AwsSdkJestMockBaseMatchers < R > extends Record < string , Function > {
10
10
/**
11
- * Asserts {@link AwsStub Aws Client Mock} received a { @link command} exact number of { @link times}
11
+ * Asserts the {@link AwsStub Client Mock} received given `Command` exact number of times.
12
12
*
13
- * @param command aws-sdk command constructor
14
- * @param times
13
+ * @example
14
+ * ```js
15
+ * expect(snsMock).toHaveReceivedCommandTimes(PublishCommand, 2);
16
+ * ```
17
+ *
18
+ * @param command AWS SDK Command type
19
+ * @param times Number of expected calls
15
20
*/
16
21
toHaveReceivedCommandTimes < TCmdInput extends object ,
17
22
TCmdOutput extends MetadataBearer > (
@@ -20,20 +25,46 @@ interface AwsSdkJestMockBaseMatchers<R> extends Record<string, Function> {
20
25
) : R ;
21
26
22
27
/**
23
- * Asserts {@link AwsStub Aws Client Mock} received a {@link command} at least one time
28
+ * Asserts the {@link AwsStub Client Mock} received given `Command` at least one time.
29
+ *
30
+ * @example
31
+ * ```js
32
+ * expect(snsMock).toHaveReceivedCommandTimes(PublishCommand);
33
+ * ```
24
34
*
25
- * @param command aws-sdk command constructor
35
+ * @param command AWS SDK Command type
26
36
*/
27
37
toHaveReceivedCommand < TCmdInput extends object ,
28
38
TCmdOutput extends MetadataBearer > (
29
39
command : new ( input : TCmdInput ) => AwsCommand < TCmdInput , TCmdOutput > ,
30
40
) : R ;
31
41
32
42
/**
33
- * Asserts {@link AwsStub Aws Client Mock} received a {@link command} at least one time with matching {@link input}
43
+ * Asserts the {@link AwsStub Client Mock} received given `Command` at least one time with matching input.
44
+ *
45
+ * @example
46
+ * ```js
47
+ * expect(snsMock).toHaveReceivedCommandWith(
48
+ * PublishCommand,
49
+ * {
50
+ * Message: 'hello world',
51
+ * },
52
+ * );
53
+ * ```
34
54
*
35
- * @param command aws-sdk command constructor
36
- * @param input
55
+ * @example
56
+ * With asymmetric matcher:
57
+ * ```js
58
+ * expect(snsMock).toHaveReceivedCommandWith(
59
+ * PublishCommand,
60
+ * {
61
+ * Message: expect.stringContaining('hello'),
62
+ * },
63
+ * );
64
+ * ```
65
+ *
66
+ * @param command AWS SDK Command type
67
+ * @param input Partial input to match
37
68
*/
38
69
toHaveReceivedCommandWith < TCmdInput extends object ,
39
70
TCmdOutput extends MetadataBearer > (
@@ -42,12 +73,23 @@ interface AwsSdkJestMockBaseMatchers<R> extends Record<string, Function> {
42
73
) : R ;
43
74
44
75
/**
45
- * Asserts {@link AwsStub Aws Client Mock} received a {@link command} as defined {@link call} number
46
- * with matching {@link input}
76
+ * Asserts the nth call to the {@link AwsStub Client Mock} was a given `Command` with matching input.
77
+ *
78
+ * @example
79
+ * The second call to `SNSClient` was a `PublishCommand` with Message 'hello world':
80
+ * ```js
81
+ * expect(snsMock).toHaveReceivedNthCommandWith(
82
+ * 2,
83
+ * PublishCommand,
84
+ * {
85
+ * Message: 'hello world',
86
+ * },
87
+ * );
88
+ * ```
47
89
*
48
- * @param call call number to assert
49
- * @param command aws-sdk command constructor
50
- * @param input
90
+ * @param call Call number
91
+ * @param command AWS SDK Command type
92
+ * @param input Partial input to match
51
93
*/
52
94
toHaveReceivedNthCommandWith < TCmdInput extends object ,
53
95
TCmdOutput extends MetadataBearer > (
@@ -57,12 +99,23 @@ interface AwsSdkJestMockBaseMatchers<R> extends Record<string, Function> {
57
99
) : R ;
58
100
59
101
/**
60
- * Asserts {@link AwsStub Aws Client Mock} received a {@link command} as defined specific {@link call}
61
- * number with matchin {@link input}
102
+ * Asserts the nth `Command` of given type sent to the {@link AwsStub Client Mock} had matching input.
103
+ *
104
+ * @example
105
+ * The second `PublishCommand` sent to `SNSClient` had Message 'hello world':
106
+ * ```js
107
+ * expect(snsMock).toHaveReceivedNthSpecificCommandWith(
108
+ * 2,
109
+ * PublishCommand,
110
+ * {
111
+ * Message: 'hello world',
112
+ * },
113
+ * );
114
+ * ```
62
115
*
63
- * @param call call number to assert
64
- * @param command aws-sdk command constructor
65
- * @param input
116
+ * @param call Call number
117
+ * @param command AWS SDK Command type
118
+ * @param input Partial input to match
66
119
*/
67
120
toHaveReceivedNthSpecificCommandWith < TCmdInput extends object , TCmdOutput extends MetadataBearer > (
68
121
call : number ,
@@ -71,18 +124,14 @@ interface AwsSdkJestMockBaseMatchers<R> extends Record<string, Function> {
71
124
) : R ;
72
125
73
126
/**
74
- * Asserts {@link AwsStub Aws Client Mock} received any command
127
+ * Asserts {@link AwsStub Client Mock} was called at least once with any `Command`.
75
128
*/
76
129
toHaveReceivedAnyCommand ( ) : R ;
77
130
}
78
131
79
132
interface AwsSdkJestMockAliasMatchers < R > extends Record < string , Function > {
80
133
/**
81
- * Asserts {@link AwsStub Aws Client Mock} received a {@link command} exact number of {@link times}
82
- *
83
- * @alias {@link AwsSdkJestMockBaseMatchers.toHaveReceivedCommandTimes }
84
- * @param command aws-sdk command constructor
85
- * @param times
134
+ * @see toHaveReceivedCommandTimes
86
135
*/
87
136
toReceiveCommandTimes < TCmdInput extends object ,
88
137
TCmdOutput extends MetadataBearer > (
@@ -91,22 +140,15 @@ interface AwsSdkJestMockAliasMatchers<R> extends Record<string, Function> {
91
140
) : R ;
92
141
93
142
/**
94
- * Asserts {@link AwsStub Aws Client Mock} received a {@link command} at least one time
95
- *
96
- * @alias {@link AwsSdkJestMockBaseMatchers.toHaveReceivedCommand }
97
- * @param command aws-sdk command constructor
143
+ * @see toHaveReceivedCommand
98
144
*/
99
145
toReceiveCommand < TCmdInput extends object ,
100
146
TCmdOutput extends MetadataBearer > (
101
147
command : new ( input : TCmdInput ) => AwsCommand < TCmdInput , TCmdOutput > ,
102
148
) : R ;
103
149
104
150
/**
105
- * Asserts {@link AwsStub Aws Client Mock} received a {@link command} at least one time with matching {@link input}
106
- *
107
- * @alias {@link AwsSdkJestMockBaseMatchers.toHaveReceivedCommandWith }
108
- * @param command aws-sdk command constructor
109
- * @param input
151
+ * @see toHaveReceivedCommandWith
110
152
*/
111
153
toReceiveCommandWith < TCmdInput extends object ,
112
154
TCmdOutput extends MetadataBearer > (
@@ -115,13 +157,7 @@ interface AwsSdkJestMockAliasMatchers<R> extends Record<string, Function> {
115
157
) : R ;
116
158
117
159
/**
118
- * Asserts {@link AwsStub Aws Client Mock} received a {@link command} as defined {@link call} number
119
- * with matching {@link input}
120
- *
121
- * @alias {@link AwsSdkJestMockBaseMatchers.toHaveReceivedNthCommandWith }
122
- * @param call call number to assert
123
- * @param command aws-sdk command constructor
124
- * @param input
160
+ * @see toHaveReceivedNthCommandWith
125
161
*/
126
162
toReceiveNthCommandWith < TCmdInput extends object ,
127
163
TCmdOutput extends MetadataBearer > (
@@ -131,12 +167,7 @@ interface AwsSdkJestMockAliasMatchers<R> extends Record<string, Function> {
131
167
) : R ;
132
168
133
169
/**
134
- * Asserts {@link AwsStub Aws Client Mock} received a {@link command} as defined specific {@link call}
135
- * number with matchin {@link input}
136
- *
137
- * @param call call number to assert
138
- * @param command aws-sdk command constructor
139
- * @param input
170
+ * @see toHaveReceivedNthSpecificCommandWith
140
171
*/
141
172
toReceiveNthSpecificCommandWith < TCmdInput extends object , TCmdOutput extends MetadataBearer > (
142
173
call : number ,
@@ -145,7 +176,7 @@ interface AwsSdkJestMockAliasMatchers<R> extends Record<string, Function> {
145
176
) : R ;
146
177
147
178
/**
148
- * Asserts { @link AwsStub Aws Client Mock} received any command
179
+ * @see toHaveReceivedAnyCommand
149
180
*/
150
181
toReceiveAnyCommand ( ) : R ;
151
182
}
0 commit comments