@@ -640,4 +640,64 @@ describe('main', () => {
640640 ) ;
641641 } ) ;
642642 } ) ;
643+
644+ describe ( 'when using an alternative registry' , ( ) => {
645+ it ( 'should use the passed registry url for the PluginManager' , async ( ) => {
646+ const spy = jest . fn ( ) ;
647+ ( PluginManager as jest . Mock ) . mockImplementation (
648+ spy . mockReturnValue ( {
649+ install : ( ) => Promise . resolve ( undefined ) ,
650+ // @ts -ignore
651+ require : jest . fn ( ) . mockImplementationOnce ( ( codemodName : string ) => ( {
652+ default : {
653+ transforms : {
654+ '18.0.0' : `${ codemodName } /path/to/18.js` ,
655+ } ,
656+ } ,
657+ } ) ) ,
658+ uninstallAll : ( ) => Promise . resolve ( ) ,
659+ } ) ,
660+ ) ;
661+
662+ await main ( [ mockPath ] , {
663+ packages : 'mylib@18.0.0' ,
664+ registry : 'https://localhost:4875' ,
665+ } ) ;
666+
667+ expect ( spy ) . toHaveBeenCalledWith (
668+ expect . objectContaining ( { npmRegistryUrl : 'https://localhost:4875' } ) ,
669+ ) ;
670+ } ) ;
671+
672+ it ( 'should use the passed registryToken for the PluginManager' , async ( ) => {
673+ const spy = jest . fn ( ) ;
674+ ( PluginManager as jest . Mock ) . mockImplementation (
675+ spy . mockReturnValue ( {
676+ install : ( ) => Promise . resolve ( undefined ) ,
677+ // @ts -ignore
678+ require : jest . fn ( ) . mockImplementationOnce ( ( codemodName : string ) => ( {
679+ default : {
680+ transforms : {
681+ '18.0.0' : `${ codemodName } /path/to/18.js` ,
682+ } ,
683+ } ,
684+ } ) ) ,
685+ uninstallAll : ( ) => Promise . resolve ( ) ,
686+ } ) ,
687+ ) ;
688+
689+ await main ( [ mockPath ] , {
690+ packages : 'mylib@18.0.0' ,
691+ registryToken : '1234ABCD=' ,
692+ } ) ;
693+
694+ expect ( spy ) . toHaveBeenCalledWith (
695+ expect . objectContaining ( {
696+ npmRegistryConfig : expect . objectContaining ( {
697+ auth : expect . objectContaining ( { token : '1234ABCD=' } ) ,
698+ } ) ,
699+ } ) ,
700+ ) ;
701+ } ) ;
702+ } ) ;
643703} ) ;
0 commit comments