@@ -131,21 +131,30 @@ function! s:FindFileBasedOnAngularServiceUnderCursor(cmd) abort
131131 endif
132132endfunction
133133
134+ function ! s: SubStr (originalstring, pattern, replacement) abort
135+ return substitute (a: originalstring , a: pattern , a: replacement , " " )
136+ endfunction
137+
134138function ! s: GenerateTestPaths (currentpath, appbasepath, testbasepath) abort
135- let l: samefilename = substitute (a: currentpath , a: appbasepath , a: testbasepath, " " )
136- let l: withcamelcasedspecsuffix = substitute ( substitute (a: currentpath , a: appbasepath , a: testbasepath, " " ), " .js" , " Spec.js" , " " )
137- let l: withdotspecsuffix = substitute ( substitute (a: currentpath , a: appbasepath , a: testbasepath, " " ), " .js" , " .spec.js" , " " )
139+ let l: samefilename = s: SubStr (a: currentpath , a: appbasepath , a: testbasepath )
140+ let l: withcamelcasedspecsuffix = s: SubStr ( s: SubStr (a: currentpath , a: appbasepath , a: testbasepath ), " .js" , " Spec.js" )
141+ let l: withdotspecsuffix = s: SubStr ( s: SubStr (a: currentpath , a: appbasepath , a: testbasepath ), " .js" , " .spec.js" )
138142 return [l: samefilename , l: withcamelcasedspecsuffix , l: withdotspecsuffix ]
139143endfunction
140144
141145function ! s: GenerateSrcPaths (currentpath, appbasepath, testbasepath) abort
142- return [substitute ( substitute (a: currentpath , a: testbasepath , a: appbasepath, " " ), " Spec.js" , " .js" , " " ),
143- \ substitute ( substitute (a: currentpath , a: testbasepath , a: appbasepath, " " ), " .spec.js" , " .js" , " " )]
146+ return [s: SubStr ( s: SubStr (a: currentpath , a: testbasepath , a: appbasepath ), " Spec.js" , " .js" ),
147+ \ s: SubStr ( s: SubStr (a: currentpath , a: testbasepath , a: appbasepath ), " .spec.js" , " .js" )]
144148endfunction
145149
146150function ! s: Alternate (cmd) abort
147151 let l: currentpath = expand (' %' )
148152 let l: possiblepathsforalternatefile = []
153+ for possiblenewpath in [s: SubStr (l: currentpath , " .js" , " _test.js" ), s: SubStr (l: currentpath , " _test.js" , " .js" )]
154+ if possiblenewpath != l: currentpath
155+ let l: possiblepathsforalternatefile = [possiblenewpath]
156+ endif
157+ endfor
149158
150159 if exists (' g:angular_source_directory' )
151160 let l: possiblesrcpaths = [g: angular_source_directory ]
0 commit comments