@@ -74,6 +74,24 @@ describe('update', () => {
7474 assert . ok ( update . indexOf ( tl ) > - 1 )
7575 } )
7676
77+ it ( 'updates complex import expressions' , async ( ) => {
78+ const update = await specifier . update (
79+ join ( fixtures , 'complexImportExpression.ts' ) ,
80+ spec => {
81+ if ( spec . value === './user.js' ) {
82+ return './other-user.js'
83+ }
84+
85+ if ( spec . value === './code.js' ) {
86+ return './other-code.js'
87+ }
88+ } ,
89+ )
90+
91+ assert . ok ( update . indexOf ( './other-user.js' ) > - 1 )
92+ assert . equal ( [ ...update . matchAll ( / o t h e r - c o d e \. j s / g) ] . length , 3 )
93+ } )
94+
7795 it ( 'works with typescript' , async ( ) => {
7896 let update = await specifier . update ( join ( fixtures , 'types.d.ts' ) , spec => {
7997 if ( spec . value === './user.js' ) {
@@ -116,6 +134,21 @@ describe('update', () => {
116134 assert . ok ( update . indexOf ( 'require("./esm.mjs")' ) > - 1 )
117135 } )
118136
137+ it ( 'updates complex require expressions' , async ( ) => {
138+ const update = await specifier . update ( join ( fixtures , 'complexRequire.js' ) , spec => {
139+ if ( spec . value === './user.js' ) {
140+ return './other-user.js'
141+ }
142+
143+ if ( spec . value === './code.js' ) {
144+ return './other-code.js'
145+ }
146+ } )
147+
148+ assert . ok ( update . indexOf ( './other-user.js' ) > - 1 )
149+ assert . equal ( [ ...update . matchAll ( / o t h e r - c o d e \. j s / g) ] . length , 3 )
150+ } )
151+
119152 it ( 'updates `resolve` from different module types' , async ( ) => {
120153 const update = await specifier . update ( join ( fixtures , 'modules.js' ) , ( { value } ) => {
121154 if ( value === './require/file.js' ) {
0 commit comments