11component extends = " coldbox.system.testing.BaseTestCase" {
22
3-
3+
44 function beforeAll () {
55 variables .mockController = createStub ();
66 variables .mockUtility = createStub ();
77 variables .mockChecksumService = createStub ();
88 variables .mockValidationService = createStub ();
99 variables .mockRequestService = createStub ();
10-
10+
1111 variables .renderService = prepareMock ( new cbwire .models .services .RenderService () );
1212 renderService .setCBWIREController ( mockController );
1313 renderService .setUtilityService ( mockUtility );
@@ -263,32 +263,55 @@ component extends="coldbox.system.testing.BaseTestCase" {
263263
264264 it ( " should return .bxm path when .bxm file exists" , function () {
265265 var input = " my.view.template" ;
266+ // simulate the components variables._path which is what is passed to the wire() method
267+ var componentPath = " my.view.template" ;
266268 var bxmAbsolutePath = expandPath ( " /my/view/template.bxm" );
267269 var cfmAbsolutePath = expandPath ( " /my/view/template.cfm" );
268270 var expectedPath = " /wires/my/view/template.bxm" ;
269271
270272 mockUtility .$( " fileExists" ).$args ( bxmAbsolutePath ).$results ( true );
271273 mockUtility .$( " fileExists" ).$args ( cfmAbsolutePath ).$results ( false );
272274
273- var result = renderService .normalizeViewPath ( input );
275+ var result = renderService .normalizeViewPath ( input , componentPath );
274276 expect ( result ).toBe ( expectedPath );
275277 });
276278
277279 it ( " should return .cfm path when only .cfm file exists" , function () {
278280 var input = " my.view.template" ;
281+ // simulate the components variables._path which is what is passed to the wire() method
282+ var component_path = " my.view.template" ;
279283 var bxmAbsolutePath = expandPath ( " /my/view/template.bxm" );
280284 var cfmAbsolutePath = expandPath ( " /my/view/template.cfm" );
281285 var expectedPath = " /wires/my/view/template.cfm" ;
282286
283287 mockUtility .$( " fileExists" ).$args ( bxmAbsolutePath ).$results ( false );
284288 mockUtility .$( " fileExists" ).$args ( cfmAbsolutePath ).$results ( true );
285289
286- var result = renderService .normalizeViewPath ( input );
290+ var result = renderService .normalizeViewPath ( input , component_path );
291+ expect ( result ).toBe ( expectedPath );
292+ });
293+
294+ it ( " should return .cfm module path when wire is located in module wires directory" , function () {
295+ var input = " modules_app.testingmodule.wires.twoFileModuleComponent" ;
296+ // simulate the components variables._path which is what is passed to the wire() method
297+ var component_path = " twoFileModuleComponent@testingmodule" ;
298+ // use full path to module wire
299+ var bxmAbsolutePath = expandPath ( " ../modules_app/testingmodule/wires/twoFileModuleComponent.bxm" );
300+ var cfmAbsolutePath = expandPath ( " ../modules_app/testingmodule/wires/twoFileModuleComponent.cfm" );
301+
302+ var expectedPath = " /modules_app/testingmodule/wires/twoFileModuleComponent.cfm" ;
303+ // mock the file exists calls for both .bxm and .cfm paths
304+ mockUtility .$( " fileExists" ).$args ( bxmAbsolutePath ).$results ( false );
305+ mockUtility .$( " fileExists" ).$args ( cfmAbsolutePath ).$results ( true );
306+
307+ var result = renderService .normalizeViewPath ( input , component_path );
287308 expect ( result ).toBe ( expectedPath );
288309 });
289310
290311 it ( " should throw when neither .bxm nor .cfm exists" , function () {
291312 var input = " my.view.template" ;
313+ // simulate the components variables._path which is what is passed to the wire() method
314+ var component_path = " my.view.template" ;
292315 var bxmAbsolutePath = expandPath ( " /nonexistent/view.bxm" );
293316 var cfmAbsolutePath = expandPath ( " /nonexistent/view.cfm" );
294317 var expectedPath = " /wires/my/view/template.cfm" ;
@@ -297,29 +320,34 @@ component extends="coldbox.system.testing.BaseTestCase" {
297320 mockUtility .$( " fileExists" ).$args ( cfmAbsolutePath ).$results ( false );
298321
299322 expect ( function () {
300- renderService .normalizeViewPath ( " nonexistent.view" );
323+ renderService .normalizeViewPath ( " nonexistent.view" , component_path );
301324 }).toThrow ( " CBWIREException" );
302325 });
303326
304327 it ( " should return path with .bxm for tmp path when .bxm exists" , function () {
305328 var input = " cbwire.models.tmp.componentName" ;
329+ // simulate the components variables._path which is what is passed to the wire() method
330+ var component_path = " cbwire.models.tmp.componentName" ;
306331
307332 mockUtility .$( " fileExists" ).$args ( expandPath ( " /cbwire/models/tmp/componentName.bxm" ) ).$results ( true );
308333 mockUtility .$( " fileExists" ).$args ( expandPath ( " /cbwire/models/tmp/componentName.cfm" ) ).$results ( false );
309334
310- var result = renderService .normalizeViewPath ( input );
335+ var result = renderService .normalizeViewPath ( input , component_path );
311336 expect ( result ).toBe ( " /cbwire/models/tmp/componentName.bxm" );
312337 });
313338
314339 it ( " should return path with .cfm for tmp path when .cfm exists" , function () {
315340 var input = " cbwire.models.tmp.componentName" ;
341+ // simulate the components variables._path which is what is passed to the wire() method
342+ var component_path = " cbwire.models.tmp.componentName" ;
316343
317344 mockUtility .$( " fileExists" ).$args ( expandPath ( " /cbwire/models/tmp/componentName.bxm" ) ).$results ( false );
318345 mockUtility .$( " fileExists" ).$args ( expandPath ( " /cbwire/models/tmp/componentName.cfm" ) ).$results ( true );
319346
320- var result = renderService .normalizeViewPath ( input );
347+ var result = renderService .normalizeViewPath ( input , component_path );
321348 expect ( result ).toBe ( " /cbwire/models/tmp/componentName.cfm" );
322349 });
350+
323351 });
324352
325353 describe ( " getTemplatePath()" , function () {
0 commit comments