1const t = require('tap') 2const validateLockfile = require('../../../lib/utils/validate-lockfile.js') 3 4t.test('identical inventory for both idealTree and virtualTree', async t => { 5 t.matchSnapshot( 6 validateLockfile( 7 new Map([ 8 ['foo', { name: 'foo', version: '1.0.0' }], 9 ['bar', { name: 'bar', version: '2.0.0' }], 10 ]), 11 new Map([ 12 ['foo', { name: 'foo', version: '1.0.0' }], 13 ['bar', { name: 'bar', version: '2.0.0' }], 14 ]) 15 ), 16 'should have no errors on identical inventories' 17 ) 18}) 19 20t.test('extra inventory items on idealTree', async t => { 21 t.matchSnapshot( 22 validateLockfile( 23 new Map([ 24 ['foo', { name: 'foo', version: '1.0.0' }], 25 ['bar', { name: 'bar', version: '2.0.0' }], 26 ]), 27 new Map([ 28 ['foo', { name: 'foo', version: '1.0.0' }], 29 ['bar', { name: 'bar', version: '2.0.0' }], 30 ['baz', { name: 'baz', version: '3.0.0' }], 31 ]) 32 ), 33 'should have missing entries error' 34 ) 35}) 36 37t.test('extra inventory items on virtualTree', async t => { 38 t.matchSnapshot( 39 validateLockfile( 40 new Map([ 41 ['foo', { name: 'foo', version: '1.0.0' }], 42 ['bar', { name: 'bar', version: '2.0.0' }], 43 ['baz', { name: 'baz', version: '3.0.0' }], 44 ]), 45 new Map([ 46 ['foo', { name: 'foo', version: '1.0.0' }], 47 ['bar', { name: 'bar', version: '2.0.0' }], 48 ]) 49 ), 50 'should have no errors if finding virtualTree extra items' 51 ) 52}) 53 54t.test('mismatching versions on inventory', async t => { 55 t.matchSnapshot( 56 validateLockfile( 57 new Map([ 58 ['foo', { name: 'foo', version: '1.0.0' }], 59 ['bar', { name: 'bar', version: '2.0.0' }], 60 ]), 61 new Map([ 62 ['foo', { name: 'foo', version: '2.0.0' }], 63 ['bar', { name: 'bar', version: '3.0.0' }], 64 ]) 65 ), 66 'should have errors for each mismatching version' 67 ) 68}) 69 70t.test('missing virtualTree inventory', async t => { 71 t.matchSnapshot( 72 validateLockfile( 73 new Map([]), 74 new Map([ 75 ['foo', { name: 'foo', version: '1.0.0' }], 76 ['bar', { name: 'bar', version: '2.0.0' }], 77 ['baz', { name: 'baz', version: '3.0.0' }], 78 ]) 79 ), 80 'should have errors for each mismatching version' 81 ) 82}) 83