@@ -420,6 +420,22 @@ require('tap').test('basic', function (t) {
420
420
// t.has(res, tests[arg], arg + ' matches expectations')
421
421
} )
422
422
423
+ var objSpec = { name : 'foo' , rawSpec : '1.2.3' }
424
+ t . equal ( npa ( objSpec , '/whatnot' ) . toString ( ) , 'foo@1.2.3' , 'parsed object' )
425
+
426
+ objSpec = { raw : './foo/bar' , where : '/here' }
427
+ t . equal ( npa ( objSpec ) . fetchSpec , '/here/foo/bar' , '`where` is reused' )
428
+
429
+ objSpec = { raw : './foo/bar' , where : '/here' }
430
+ t . equal ( npa ( objSpec , '/whatnot' ) . fetchSpec , '/whatnot/foo/bar' , '`where` arg overrides the one in the spec object' )
431
+
432
+ t . equal ( npa ( npa ( 'foo@1.2.3' ) ) . toString ( ) , 'foo@1.2.3' , 'spec is passthrough' )
433
+
434
+ var parsedSpec = npa ( './foo' , './here' )
435
+ t . equal ( npa ( parsedSpec ) , parsedSpec , 'reused if no where' )
436
+ t . equal ( npa ( parsedSpec , './here' ) , parsedSpec , 'reused if where matches' )
437
+ t . notEqual ( npa ( parsedSpec , './there' ) , parsedSpec , 'new instance if where does not match' )
438
+ t . notEqual ( npa ( parsedSpec , './there' ) . fetchSpec , '/there/foo' , 'new instance has new where' )
423
439
// Completely unreasonable invalid garbage throws an error
424
440
t . throws ( function ( ) {
425
441
t . comment ( npa ( 'this is not a \0 valid package name or url' ) )
0 commit comments