@@ -60,6 +60,50 @@ describe('format', () => {
6060 }
6161 } )
6262
63+ describe ( 'diff' , ( ) => {
64+ it ( 'basic' , async ( ) => {
65+ const tempDir = await fs . mkdtemp ( path . join ( os . tmpdir ( ) , 'npm-check-updates-' ) )
66+ const pkgFile = path . join ( tempDir , 'package.json' )
67+ await fs . writeFile (
68+ pkgFile ,
69+ JSON . stringify ( {
70+ dependencies : {
71+ 'ncu-test-v2' : '^1.0.0' ,
72+ } ,
73+ } ) ,
74+ 'utf-8' ,
75+ )
76+ try {
77+ const { stdout } = await spawn ( 'node' , [ bin , '--format' , 'diff' ] , { } , { cwd : tempDir } )
78+ stdout . should . include ( 'https://npmdiff.dev/ncu-test-v2/1.0.0/2.0.0' )
79+ } finally {
80+ await removeDir ( tempDir )
81+ }
82+ } )
83+
84+ // https://github.com/raineorshine/npm-check-updates/pull/1603/changes/BASE..4ab36b01b5f90e8d2563361a3b18ed2b3f9d2280#r2865386584
85+ it ( 'encodeURIComponent' , async ( ) => {
86+ const tempDir = await fs . mkdtemp ( path . join ( os . tmpdir ( ) , 'npm-check-updates-' ) )
87+ const pkgFile = path . join ( tempDir , 'package.json' )
88+ await fs . writeFile (
89+ pkgFile ,
90+ JSON . stringify ( {
91+ dependencies : {
92+ '@types/jsonlines' : '0.1.0' ,
93+ } ,
94+ } ) ,
95+ 'utf-8' ,
96+ )
97+ try {
98+ const { stdout } = await spawn ( 'node' , [ bin , '--format' , 'diff' ] , { } , { cwd : tempDir } )
99+ // purposefully omit 'to' version since this is a live package
100+ stdout . should . include ( 'https://npmdiff.dev/%40types%2Fjsonlines/0.1.0/' )
101+ } finally {
102+ await removeDir ( tempDir )
103+ }
104+ } )
105+ } )
106+
63107 // do not stubVersions here, because we need to test if if time is parsed correctly from npm-registry-fetch
64108 it ( '--format time' , async ( ) => {
65109 const timestamp = '2020-04-27T21:48:11.660Z'
0 commit comments