@@ -12,7 +12,7 @@ describe('resolve base urls', () => {
1212 const findDownloadURL = findTags . bind (
1313 undefined ,
1414 'downloadURL' ,
15- Fixtures . downloadURL ,
15+ Fixtures . downloadURLWithUserjs ,
1616 ) ;
1717
1818 beforeEach ( async ( ) => {
@@ -26,7 +26,7 @@ describe('resolve base urls', () => {
2626 const findUpdateURLByMetajs = findTags . bind (
2727 undefined ,
2828 'updateURL' ,
29- Fixtures . updateURLByMetajs ,
29+ Fixtures . updateURLWithMetajs ,
3030 ) ;
3131
3232 const output = await compile ( input , {
@@ -53,11 +53,11 @@ describe('resolve base urls', () => {
5353 expect ( findUpdateURLByMetajs ( metaJs ) ) . toHaveLength ( 1 ) ;
5454 } ) ;
5555
56- it ( 'should resolve updateURL by userjs' , async ( ) => {
56+ it ( 'should resolve updateURL with updateBaseURL and userjs' , async ( ) => {
5757 const findUpdateURLByUserjs = findTags . bind (
5858 undefined ,
5959 'updateURL' ,
60- Fixtures . updateURLByUserjs ,
60+ Fixtures . updateURLWithUserjs ,
6161 ) ;
6262
6363 const output = await compile ( input , {
@@ -79,11 +79,11 @@ describe('resolve base urls', () => {
7979 expect ( findUpdateURLByUserjs ( userJs ) ) . toHaveLength ( 1 ) ;
8080 } ) ;
8181
82- it ( 'should resolve updateURL by downloadURL ' , async ( ) => {
82+ it ( 'should resolve updateURL by downloadBaseURL and userjs ' , async ( ) => {
8383 const findUpdateURLByDownloadURL = findTags . bind (
8484 undefined ,
8585 'updateURL' ,
86- Fixtures . downloadURL ,
86+ Fixtures . downloadURLWithUserjs ,
8787 ) ;
8888
8989 const output = await compile ( input , {
@@ -103,4 +103,29 @@ describe('resolve base urls', () => {
103103 expect ( findDownloadURL ( userJs ) ) . toHaveLength ( 1 ) ;
104104 expect ( findUpdateURLByDownloadURL ( userJs ) ) . toHaveLength ( 1 ) ;
105105 } ) ;
106+
107+ it ( 'should resolve updateURL by downloadBaseURL and metajs' , async ( ) => {
108+ const findUpdateURLByDownloadURL = findTags . bind (
109+ undefined ,
110+ 'updateURL' ,
111+ Fixtures . downloadURLWithMetajs ,
112+ ) ;
113+
114+ const output = await compile ( input , {
115+ ...Fixtures . webpackConfig ,
116+ plugins : [
117+ new UserscriptPlugin ( {
118+ downloadBaseURL : new URL ( 'http://download.example.com' ) ,
119+ metajs : true ,
120+ } ) ,
121+ ] ,
122+ } ) ;
123+
124+ const userJs = output
125+ . readFileSync ( '/dist/output.user.js' )
126+ . toString ( 'utf-8' ) ;
127+
128+ expect ( findDownloadURL ( userJs ) ) . toHaveLength ( 1 ) ;
129+ expect ( findUpdateURLByDownloadURL ( userJs ) ) . toHaveLength ( 1 ) ;
130+ } ) ;
106131} ) ;
0 commit comments