@@ -43,6 +43,9 @@ describe('promptForChange _promptForPackageChange', () => {
43
43
expect . objectContaining ( { name : 'comment' , type : 'autocomplete' } ) ,
44
44
] ;
45
45
46
+ /** Info for the default package used in tests */
47
+ const pkgInfo = defaultQuestionsParams . packageInfos [ pkg ] ;
48
+
46
49
/** Wait for the prompt to finish rendering (simulates real user input) */
47
50
const waitForPrompt = ( ) => new Promise ( resolve => process . nextTick ( resolve ) ) ;
48
51
@@ -61,7 +64,7 @@ describe('promptForChange _promptForPackageChange', () => {
61
64
} ) ;
62
65
63
66
it ( 'returns an empty object and logs nothing if there are no questions' , async ( ) => {
64
- const answers = await _promptForPackageChange ( [ ] , pkg ) ;
67
+ const answers = await _promptForPackageChange ( [ ] , pkgInfo ) ;
65
68
expect ( answers ) . toEqual ( { } ) ;
66
69
expect ( logs . mocks . log ) . not . toHaveBeenCalled ( ) ;
67
70
} ) ;
@@ -70,13 +73,15 @@ describe('promptForChange _promptForPackageChange', () => {
70
73
const questions = getQuestionsForPackage ( defaultQuestionsParams ) ;
71
74
expect ( questions ) . toEqual ( expectedQuestions ) ;
72
75
73
- const answersPromise = _promptForPackageChange ( questions ! , pkg ) ;
76
+ const answersPromise = _promptForPackageChange ( questions ! , pkgInfo ) ;
74
77
75
78
// input: press enter twice to use defaults (with a pause in between to simulate real user input)
76
79
await stdin . sendByChar ( '\n\n' ) ;
77
80
const answers = await answersPromise ;
78
81
79
- expect ( logs . getMockLines ( 'log' ) ) . toMatchInlineSnapshot ( `"Please describe the changes for: foo"` ) ;
82
+ expect ( logs . getMockLines ( 'log' ) ) . toMatchInlineSnapshot (
83
+ `"Please describe the changes for: foo (currently v1.0.0)"`
84
+ ) ;
80
85
expect ( stdout . getOutput ( ) ) . toMatchInlineSnapshot ( `
81
86
"? Change type » - Use arrow-keys. Return to submit.
82
87
> Patch - bug fixes; no API changes
@@ -99,7 +104,7 @@ describe('promptForChange _promptForPackageChange', () => {
99
104
} ) ;
100
105
expect ( questions ) . toEqual ( expectedQuestions . slice ( 1 ) ) ;
101
106
102
- const answerPromise = _promptForPackageChange ( questions ! , pkg ) ;
107
+ const answerPromise = _promptForPackageChange ( questions ! , pkgInfo ) ;
103
108
await waitForPrompt ( ) ;
104
109
expect ( stdout . lastOutput ( ) ) . toMatchInlineSnapshot ( `
105
110
"? Describe changes (type or choose one) »
@@ -112,7 +117,9 @@ describe('promptForChange _promptForPackageChange', () => {
112
117
await stdin . sendByChar ( 'abc\n' ) ;
113
118
const answers = await answerPromise ;
114
119
115
- expect ( logs . getMockLines ( 'log' ) ) . toMatchInlineSnapshot ( `"Please describe the changes for: foo"` ) ;
120
+ expect ( logs . getMockLines ( 'log' ) ) . toMatchInlineSnapshot (
121
+ `"Please describe the changes for: foo (currently v1.0.0)"`
122
+ ) ;
116
123
expect ( stdout . getOutput ( ) ) . toMatchInlineSnapshot ( `
117
124
"? Describe changes (type or choose one) » a
118
125
? Describe changes (type or choose one) » ab
@@ -130,7 +137,7 @@ describe('promptForChange _promptForPackageChange', () => {
130
137
} ) ;
131
138
expect ( questions ) . toEqual ( expectedQuestions . slice ( 1 ) ) ;
132
139
133
- const answerPromise = _promptForPackageChange ( questions ! , pkg ) ;
140
+ const answerPromise = _promptForPackageChange ( questions ! , pkgInfo ) ;
134
141
await waitForPrompt ( ) ;
135
142
expect ( stdout . lastOutput ( ) ) . toMatchInlineSnapshot ( `
136
143
"? Describe changes (type or choose one) »
@@ -144,7 +151,9 @@ describe('promptForChange _promptForPackageChange', () => {
144
151
await stdin . sendByChar ( '\n' ) ;
145
152
const answers = await answerPromise ;
146
153
147
- expect ( logs . getMockLines ( 'log' ) ) . toMatchInlineSnapshot ( `"Please describe the changes for: foo"` ) ;
154
+ expect ( logs . getMockLines ( 'log' ) ) . toMatchInlineSnapshot (
155
+ `"Please describe the changes for: foo (currently v1.0.0)"`
156
+ ) ;
148
157
expect ( stdout . getOutput ( ) ) . toMatchInlineSnapshot ( `
149
158
"? Describe changes (type or choose one) » abc
150
159
√ Describe changes (type or choose one) » abc"
@@ -160,7 +169,7 @@ describe('promptForChange _promptForPackageChange', () => {
160
169
} ) ;
161
170
expect ( questions ) . toEqual ( expectedQuestions . slice ( 1 ) ) ;
162
171
163
- const answerPromise = _promptForPackageChange ( questions ! , pkg ) ;
172
+ const answerPromise = _promptForPackageChange ( questions ! , pkgInfo ) ;
164
173
await waitForPrompt ( ) ;
165
174
expect ( stdout . lastOutput ( ) ) . toMatchInlineSnapshot ( `
166
175
"? Describe changes (type or choose one) »
@@ -173,7 +182,9 @@ describe('promptForChange _promptForPackageChange', () => {
173
182
stdin . send ( 'abc\n' ) ;
174
183
const answers = await answerPromise ;
175
184
176
- expect ( logs . getMockLines ( 'log' ) ) . toMatchInlineSnapshot ( `"Please describe the changes for: foo"` ) ;
185
+ expect ( logs . getMockLines ( 'log' ) ) . toMatchInlineSnapshot (
186
+ `"Please describe the changes for: foo (currently v1.0.0)"`
187
+ ) ;
177
188
expect ( stdout . getOutput ( ) ) . toMatchInlineSnapshot ( `""` ) ;
178
189
expect ( answers ) . toEqual ( { comment : 'abc' } ) ;
179
190
} ) ;
@@ -183,7 +194,7 @@ describe('promptForChange _promptForPackageChange', () => {
183
194
const questions = getQuestionsForPackage ( { ...defaultQuestionsParams , recentMessages } ) ;
184
195
expect ( questions ) . toEqual ( expectedQuestions ) ;
185
196
186
- const answerPromise = _promptForPackageChange ( questions ! , pkg ) ;
197
+ const answerPromise = _promptForPackageChange ( questions ! , pkgInfo ) ;
187
198
188
199
// arrow down to select the third type
189
200
stdin . emitKey ( { name : 'down' } ) ;
@@ -233,7 +244,7 @@ describe('promptForChange _promptForPackageChange', () => {
233
244
} ) ;
234
245
expect ( questions ) . toEqual ( expectedQuestions . slice ( 1 ) ) ;
235
246
236
- const answerPromise = _promptForPackageChange ( questions ! , pkg ) ;
247
+ const answerPromise = _promptForPackageChange ( questions ! , pkgInfo ) ;
237
248
238
249
// type "ba" and press enter to select "bar"
239
250
await stdin . sendByChar ( 'ba\n' ) ;
@@ -264,7 +275,7 @@ describe('promptForChange _promptForPackageChange', () => {
264
275
} ) ;
265
276
expect ( questions ) . toEqual ( expectedQuestions . slice ( 1 ) ) ;
266
277
267
- const answerPromise = _promptForPackageChange ( questions ! , pkg ) ;
278
+ const answerPromise = _promptForPackageChange ( questions ! , pkgInfo ) ;
268
279
269
280
// type "b", press backspace to delete it, press enter to select foo
270
281
await stdin . sendByChar ( 'b' ) ;
@@ -294,7 +305,7 @@ describe('promptForChange _promptForPackageChange', () => {
294
305
const questions = getQuestionsForPackage ( defaultQuestionsParams ) ;
295
306
expect ( questions ) . toEqual ( expectedQuestions ) ;
296
307
297
- const answerPromise = _promptForPackageChange ( questions ! , pkg ) ;
308
+ const answerPromise = _promptForPackageChange ( questions ! , pkgInfo ) ;
298
309
299
310
// answer the first question
300
311
await stdin . sendByChar ( '\n' ) ;
@@ -305,7 +316,7 @@ describe('promptForChange _promptForPackageChange', () => {
305
316
const answers = await answerPromise ;
306
317
307
318
expect ( logs . getMockLines ( 'log' ) ) . toMatchInlineSnapshot ( `
308
- "Please describe the changes for: foo
319
+ "Please describe the changes for: foo (currently v1.0.0)
309
320
Cancelled, no change files are written"
310
321
` ) ;
311
322
0 commit comments