@@ -41,6 +41,9 @@ describe('promptForChange _promptForPackageChange', () => {
4141 expect . objectContaining ( { name : 'comment' , type : 'autocomplete' } ) ,
4242 ] ;
4343
44+ /** Info for the default package used in tests */
45+ const pkgInfo = defaultQuestionsParams . packageInfos [ pkg ] ;
46+
4447 /** Wait for the prompt to finish rendering (simulates real user input) */
4548 const waitForPrompt = ( ) => new Promise ( resolve => process . nextTick ( resolve ) ) ;
4649
@@ -59,7 +62,7 @@ describe('promptForChange _promptForPackageChange', () => {
5962 } ) ;
6063
6164 it ( 'returns an empty object and logs nothing if there are no questions' , async ( ) => {
62- const answers = await _promptForPackageChange ( [ ] , pkg ) ;
65+ const answers = await _promptForPackageChange ( [ ] , pkgInfo ) ;
6366 expect ( answers ) . toEqual ( { } ) ;
6467 expect ( logs . mocks . log ) . not . toHaveBeenCalled ( ) ;
6568 } ) ;
@@ -68,13 +71,15 @@ describe('promptForChange _promptForPackageChange', () => {
6871 const questions = getQuestionsForPackage ( defaultQuestionsParams ) ;
6972 expect ( questions ) . toEqual ( expectedQuestions ) ;
7073
71- const answersPromise = _promptForPackageChange ( questions ! , pkg ) ;
74+ const answersPromise = _promptForPackageChange ( questions ! , pkgInfo ) ;
7275
7376 // input: press enter twice to use defaults (with a pause in between to simulate real user input)
7477 await stdin . sendByChar ( '\n\n' ) ;
7578 const answers = await answersPromise ;
7679
77- expect ( logs . getMockLines ( 'log' ) ) . toMatchInlineSnapshot ( `"Please describe the changes for: foo"` ) ;
80+ expect ( logs . getMockLines ( 'log' ) ) . toMatchInlineSnapshot (
81+ `"Please describe the changes for: foo (currently v1.0.0)"`
82+ ) ;
7883 expect ( stdout . getOutput ( ) ) . toMatchInlineSnapshot ( `
7984 "? Change type » - Use arrow-keys. Return to submit.
8085 > Patch - bug fixes; no API changes
@@ -97,7 +102,7 @@ describe('promptForChange _promptForPackageChange', () => {
97102 } ) ;
98103 expect ( questions ) . toEqual ( expectedQuestions . slice ( 1 ) ) ;
99104
100- const answerPromise = _promptForPackageChange ( questions ! , pkg ) ;
105+ const answerPromise = _promptForPackageChange ( questions ! , pkgInfo ) ;
101106 await waitForPrompt ( ) ;
102107 expect ( stdout . lastOutput ( ) ) . toMatchInlineSnapshot ( `
103108 "? Describe changes (type or choose one) »
@@ -110,7 +115,9 @@ describe('promptForChange _promptForPackageChange', () => {
110115 await stdin . sendByChar ( 'abc\n' ) ;
111116 const answers = await answerPromise ;
112117
113- expect ( logs . getMockLines ( 'log' ) ) . toMatchInlineSnapshot ( `"Please describe the changes for: foo"` ) ;
118+ expect ( logs . getMockLines ( 'log' ) ) . toMatchInlineSnapshot (
119+ `"Please describe the changes for: foo (currently v1.0.0)"`
120+ ) ;
114121 expect ( stdout . getOutput ( ) ) . toMatchInlineSnapshot ( `
115122 "? Describe changes (type or choose one) » a
116123 ? Describe changes (type or choose one) » ab
@@ -128,7 +135,7 @@ describe('promptForChange _promptForPackageChange', () => {
128135 } ) ;
129136 expect ( questions ) . toEqual ( expectedQuestions . slice ( 1 ) ) ;
130137
131- const answerPromise = _promptForPackageChange ( questions ! , pkg ) ;
138+ const answerPromise = _promptForPackageChange ( questions ! , pkgInfo ) ;
132139 await waitForPrompt ( ) ;
133140 expect ( stdout . lastOutput ( ) ) . toMatchInlineSnapshot ( `
134141 "? Describe changes (type or choose one) »
@@ -142,7 +149,9 @@ describe('promptForChange _promptForPackageChange', () => {
142149 await stdin . sendByChar ( '\n' ) ;
143150 const answers = await answerPromise ;
144151
145- expect ( logs . getMockLines ( 'log' ) ) . toMatchInlineSnapshot ( `"Please describe the changes for: foo"` ) ;
152+ expect ( logs . getMockLines ( 'log' ) ) . toMatchInlineSnapshot (
153+ `"Please describe the changes for: foo (currently v1.0.0)"`
154+ ) ;
146155 expect ( stdout . getOutput ( ) ) . toMatchInlineSnapshot ( `
147156 "? Describe changes (type or choose one) » abc
148157 √ Describe changes (type or choose one) » abc"
@@ -158,7 +167,7 @@ describe('promptForChange _promptForPackageChange', () => {
158167 } ) ;
159168 expect ( questions ) . toEqual ( expectedQuestions . slice ( 1 ) ) ;
160169
161- const answerPromise = _promptForPackageChange ( questions ! , pkg ) ;
170+ const answerPromise = _promptForPackageChange ( questions ! , pkgInfo ) ;
162171 await waitForPrompt ( ) ;
163172 expect ( stdout . lastOutput ( ) ) . toMatchInlineSnapshot ( `
164173 "? Describe changes (type or choose one) »
@@ -171,7 +180,9 @@ describe('promptForChange _promptForPackageChange', () => {
171180 stdin . send ( 'abc\n' ) ;
172181 const answers = await answerPromise ;
173182
174- expect ( logs . getMockLines ( 'log' ) ) . toMatchInlineSnapshot ( `"Please describe the changes for: foo"` ) ;
183+ expect ( logs . getMockLines ( 'log' ) ) . toMatchInlineSnapshot (
184+ `"Please describe the changes for: foo (currently v1.0.0)"`
185+ ) ;
175186 expect ( stdout . getOutput ( ) ) . toMatchInlineSnapshot ( `""` ) ;
176187 expect ( answers ) . toEqual ( { comment : 'abc' } ) ;
177188 } ) ;
@@ -181,7 +192,7 @@ describe('promptForChange _promptForPackageChange', () => {
181192 const questions = getQuestionsForPackage ( { ...defaultQuestionsParams , recentMessages } ) ;
182193 expect ( questions ) . toEqual ( expectedQuestions ) ;
183194
184- const answerPromise = _promptForPackageChange ( questions ! , pkg ) ;
195+ const answerPromise = _promptForPackageChange ( questions ! , pkgInfo ) ;
185196
186197 // arrow down to select the third type
187198 stdin . emitKey ( { name : 'down' } ) ;
@@ -231,7 +242,7 @@ describe('promptForChange _promptForPackageChange', () => {
231242 } ) ;
232243 expect ( questions ) . toEqual ( expectedQuestions . slice ( 1 ) ) ;
233244
234- const answerPromise = _promptForPackageChange ( questions ! , pkg ) ;
245+ const answerPromise = _promptForPackageChange ( questions ! , pkgInfo ) ;
235246
236247 // type "ba" and press enter to select "bar"
237248 await stdin . sendByChar ( 'ba\n' ) ;
@@ -262,7 +273,7 @@ describe('promptForChange _promptForPackageChange', () => {
262273 } ) ;
263274 expect ( questions ) . toEqual ( expectedQuestions . slice ( 1 ) ) ;
264275
265- const answerPromise = _promptForPackageChange ( questions ! , pkg ) ;
276+ const answerPromise = _promptForPackageChange ( questions ! , pkgInfo ) ;
266277
267278 // type "b", press backspace to delete it, press enter to select foo
268279 await stdin . sendByChar ( 'b' ) ;
@@ -292,7 +303,7 @@ describe('promptForChange _promptForPackageChange', () => {
292303 const questions = getQuestionsForPackage ( defaultQuestionsParams ) ;
293304 expect ( questions ) . toEqual ( expectedQuestions ) ;
294305
295- const answerPromise = _promptForPackageChange ( questions ! , pkg ) ;
306+ const answerPromise = _promptForPackageChange ( questions ! , pkgInfo ) ;
296307
297308 // answer the first question
298309 await stdin . sendByChar ( '\n' ) ;
@@ -303,7 +314,7 @@ describe('promptForChange _promptForPackageChange', () => {
303314 const answers = await answerPromise ;
304315
305316 expect ( logs . getMockLines ( 'log' ) ) . toMatchInlineSnapshot ( `
306- "Please describe the changes for: foo
317+ "Please describe the changes for: foo (currently v1.0.0)
307318 Cancelled, no change files are written"
308319 ` ) ;
309320
0 commit comments