@@ -268,14 +268,55 @@ t.test('npm pkg', async t => {
268268 )
269269} )
270270
271+ t . test ( 'npm update --no-save --no-package-lock' , async t => {
272+ // setup, manually reset dep value
273+ await exec ( `${ npmBin } pkg set dependencies.abbrev==1.0.4` )
274+ await exec ( `${ npmBin } install` )
275+ await exec ( `${ npmBin } pkg set dependencies.abbrev=^1.0.4` )
276+
277+ const cmd = `${ npmBin } update --no-save --no-package-lock`
278+ await exec ( cmd )
279+
280+ t . equal (
281+ JSON . parse ( readFile ( 'package.json' ) ) . dependencies . abbrev ,
282+ '^1.0.4' ,
283+ 'should have expected update --no-save --no-package-lock package.json result'
284+ )
285+ t . equal (
286+ JSON . parse ( readFile ( 'package-lock.json' ) ) . packages [ 'node_modules/abbrev' ] . version ,
287+ '1.0.4' ,
288+ 'should have expected update --no-save --no-package-lock lockfile result'
289+ )
290+ } )
291+
292+ t . test ( 'npm update --no-save' , async t => {
293+ const cmd = `${ npmBin } update --no-save`
294+ await exec ( cmd )
295+
296+ t . equal (
297+ JSON . parse ( readFile ( 'package.json' ) ) . dependencies . abbrev ,
298+ '^1.0.4' ,
299+ 'should have expected update --no-save package.json result'
300+ )
301+ t . equal (
302+ JSON . parse ( readFile ( 'package-lock.json' ) ) . packages [ 'node_modules/abbrev' ] . version ,
303+ '1.1.1' ,
304+ 'should have expected update --no-save lockfile result'
305+ )
306+ } )
307+
271308t . test ( 'npm update --save' , async t => {
272309 const cmd = `${ npmBin } update --save`
273- const cmdRes = await exec ( cmd )
310+ await exec ( cmd )
274311
275- t . matchSnapshot ( cmdRes . replace ( / i n .* s / , '' ) ,
276- 'should have expected update --save reify output' )
277- t . matchSnapshot ( readFile ( 'package.json' ) ,
278- 'should have expected update --save package.json result' )
279- t . matchSnapshot ( readFile ( 'package-lock.json' ) ,
280- 'should have expected update --save lockfile result' )
312+ t . equal (
313+ JSON . parse ( readFile ( 'package.json' ) ) . dependencies . abbrev ,
314+ '^1.1.1' ,
315+ 'should have expected update --save package.json result'
316+ )
317+ t . equal (
318+ JSON . parse ( readFile ( 'package-lock.json' ) ) . packages [ 'node_modules/abbrev' ] . version ,
319+ '1.1.1' ,
320+ 'should have expected update --save lockfile result'
321+ )
281322} )
0 commit comments