@@ -50,7 +50,25 @@ test('publishPackage() calls npm publish function with the given manifest and ta
50
50
t . deepEqual ( publish . firstCall . args , [
51
51
{ name : 'the-name' , version : 'the-version' } ,
52
52
tarData ,
53
- { defaultTag : 'latest' , forceAuth : { alwaysAuth : true , token : 'the-token' } }
53
+ { defaultTag : 'latest' , forceAuth : { alwaysAuth : true , token : 'the-token' } , registry : undefined }
54
+ ] ) ;
55
+ } ) ;
56
+
57
+ test ( 'publishPackage() calls npm publish function with custom registry' , async ( t ) => {
58
+ const publish = fake . resolves ( undefined ) ;
59
+ const registryClient = registryClientFactory ( { publish } ) ;
60
+ const tarData = Buffer . from ( [ 1 , 2 , 3 , 4 ] ) ;
61
+
62
+ await registryClient . publishPackage ( { name : 'the-name' , version : 'the-version' } , tarData , {
63
+ token : 'the-token' ,
64
+ registryUrl : 'the-url'
65
+ } ) ;
66
+
67
+ t . is ( publish . callCount , 1 ) ;
68
+ t . deepEqual ( publish . firstCall . args , [
69
+ { name : 'the-name' , version : 'the-version' } ,
70
+ tarData ,
71
+ { defaultTag : 'latest' , forceAuth : { alwaysAuth : true , token : 'the-token' } , registry : 'the-url' }
54
72
] ) ;
55
73
} ) ;
56
74
@@ -69,7 +87,29 @@ test('fetchLatestVersion() fetches the correct package endpoint with the correct
69
87
'/the-name' ,
70
88
{
71
89
forceAuth : { alwaysAuth : true , token : 'the-token' } ,
72
- headers : { accept : 'application/vnd.npm.install-v1+json' }
90
+ headers : { accept : 'application/vnd.npm.install-v1+json' } ,
91
+ registry : undefined
92
+ }
93
+ ] ) ;
94
+ } ) ;
95
+
96
+ test ( 'fetchLatestVersion() fetches the correct package endpoint with the correct authentication settings and headers when using a custom registry' , async ( t ) => {
97
+ const npmFetchJson = fake . resolves ( {
98
+ name : '' ,
99
+ 'dist-tags' : { latest : '1' } ,
100
+ versions : { 1 : { dist : { shasum : '' , tarball : '' } } }
101
+ } ) ;
102
+ const registryClient = registryClientFactory ( { npmFetchJson } ) ;
103
+
104
+ await registryClient . fetchLatestVersion ( 'the-name' , { token : 'the-token' , registryUrl : 'the-url' } ) ;
105
+
106
+ t . is ( npmFetchJson . callCount , 1 ) ;
107
+ t . deepEqual ( npmFetchJson . firstCall . args , [
108
+ '/the-name' ,
109
+ {
110
+ forceAuth : { alwaysAuth : true , token : 'the-token' } ,
111
+ headers : { accept : 'application/vnd.npm.install-v1+json' } ,
112
+ registry : 'the-url'
73
113
}
74
114
] ) ;
75
115
} ) ;
0 commit comments