@@ -496,6 +496,40 @@ describe('Component & Jet Pack Tests', () => {
496496 assert . ok ( componentJson . properties , "Properties not found in component.json" ) ;
497497 } ) ;
498498 }
499+ it ( `should be built in ${ appName } /web/js/jet-composites/${ component } ` , ( ) => {
500+ const appDir = util . getAppDir ( appName ) ;
501+ const builtComponentPath = path . join ( appDir , 'web' , 'js' , 'jet-composites' , component , DEFAULT_COMPONENT_VERSION ) ;
502+ const exists = fs . pathExistsSync ( builtComponentPath ) ;
503+ assert . ok ( exists , builtComponentPath ) ;
504+ } ) ;
505+ it ( `should be built in ${ appName } /web/js/jet-composites/${ component } when unversioned is set to true in oraclejetconfig file` , async ( ) => {
506+ const appDir = util . getAppDir ( appName ) ;
507+ const { pathToApp } = util . getAppPathData ( appName ) ;
508+ const builtUnversionedComponentPath = path . join ( pathToApp , 'web' , 'js' , 'jet-composites' , component ) ;
509+ let oracleJetConfigJson = fs . readJSONSync ( path . join ( pathToApp , 'oraclejetconfig.json' ) ) ;
510+ // Modify the oraclejetconfig json:
511+ oracleJetConfigJson . unversioned = true ;
512+ // Re-write the json:
513+ fs . writeJSONSync ( path . join ( pathToApp , 'oraclejetconfig.json' ) , oracleJetConfigJson , { deference : true } ) ;
514+ await util . execCmd ( `${ util . OJET_APP_COMMAND } build component ${ component } ` , {
515+ cwd : appDir
516+ } , true , true ) ;
517+ assert . ok ( fs . existsSync ( builtUnversionedComponentPath ) , `${ component } has a versioned path in the staging folder` ) ;
518+ } ) ;
519+ it ( `should be built in ${ appName } /web/js/jet-composites/${ component } /${ DEFAULT_PACK_VERSION } when unversioned is set to false in oraclejetconfig file` , async ( ) => {
520+ const appDir = util . getAppDir ( appName ) ;
521+ const { pathToApp } = util . getAppPathData ( appName ) ;
522+ const builtVersionedComponentPath = path . join ( appDir , 'web' , 'js' , 'jet-composites' , component , DEFAULT_PACK_VERSION ) ;
523+ let oracleJetConfigJson = fs . readJSONSync ( path . join ( pathToApp , 'oraclejetconfig.json' ) ) ;
524+ // Modify the oraclejetconfig json:
525+ oracleJetConfigJson . unversioned = false ;
526+ // Re-write the json:
527+ fs . writeJSONSync ( path . join ( pathToApp , 'oraclejetconfig.json' ) , oracleJetConfigJson , { deference : true } ) ;
528+ await util . execCmd ( `${ util . OJET_APP_COMMAND } build component ${ component } ` , {
529+ cwd : appDir
530+ } , true , true ) ;
531+ assert . ok ( fs . existsSync ( builtVersionedComponentPath ) , `${ component } has an unversioned path in the staging folder` ) ;
532+ } ) ;
499533 } )
500534 }
501535
@@ -897,7 +931,7 @@ describe('Component & Jet Pack Tests', () => {
897931 } ) ;
898932 }
899933
900- function omitComponentVerstionTest ( {
934+ function omitComponentVersionTest ( {
901935 appName
902936 } ) {
903937 describe ( `Build ${ appName } with --${ util . OMIT_COMPONENT_VERSION_FLAG } ` , ( ) => {
@@ -1325,7 +1359,7 @@ describe('Component & Jet Pack Tests', () => {
13251359 } ) ;
13261360 describe ( `ojet build --${ util . OMIT_COMPONENT_VERSION_FLAG } ` , ( ) => {
13271361 util . runComponentTestInAllTestApps ( {
1328- test : omitComponentVerstionTest
1362+ test : omitComponentVersionTest
13291363 } ) ;
13301364 } ) ;
13311365 describe ( 'ojet build (component exists in both exchange and src folders)' , ( ) => {
@@ -1557,18 +1591,33 @@ describe('Component & Jet Pack Tests', () => {
15571591 }
15581592 } ) ;
15591593 if ( scriptsFolder === 'ts' ) {
1560- it ( 'should add a top-level content of type module in component.json' , ( ) => {
1561- const pathToComponentJson = util . getAppDir ( path . join (
1594+ it ( 'should add a top-level content of type module in component.json and create folder common with the module in src folder ' , ( ) => {
1595+ const pathToSrcFolder = path . join (
15621596 util . getAppDir ( appName ) ,
15631597 'src' ,
15641598 scriptsFolder ,
15651599 'jet-composites' ,
1566- pack ,
1567- 'component.json'
1568- ) ) ;
1600+ pack
1601+ ) ;
1602+ const pathToComponentJson = path . join ( pathToSrcFolder , 'component.json' ) ;
1603+ const pathToModule = path . join ( pathToSrcFolder , 'common' , 'someFunction' ) ;
1604+ if ( ! fs . existsSync ( pathToModule ) ) {
1605+ fs . mkdirSync (
1606+ pathToModule ,
1607+ {
1608+ recursive : true
1609+ }
1610+ )
1611+ }
1612+ fs . writeFileSync ( path . join ( pathToModule , 'index.ts' ) , '// Test file.' ) ;
15691613 let componentJson = fs . readJSONSync ( pathToComponentJson ) ;
15701614 let hasContentModule = false ;
1571- componentJson . contents . push ( { 'name' : 'common/someFunction' , 'type' : 'module' , 'directImport' : true } ) ;
1615+ componentJson . contents . push ( {
1616+ 'name' : 'someFunction' ,
1617+ 'main' : 'common/someFunction' ,
1618+ 'type' : 'module' ,
1619+ 'directImport' : true
1620+ } ) ;
15721621 const errorMessage = 'pack does not have contents attribute with type module in component.json' ;
15731622 fs . writeJSONSync ( pathToComponentJson , componentJson ) ;
15741623 fs . readJSONSync ( pathToComponentJson ) . contents . forEach (
@@ -1578,7 +1627,9 @@ describe('Component & Jet Pack Tests', () => {
15781627 return ;
15791628 }
15801629 } ) ;
1630+ const moduleExists = fs . existsSync ( path . join ( pathToModule , 'index.ts' ) ) ;
15811631 assert . equal ( hasContentModule , true , errorMessage ) ;
1632+ assert . ok ( moduleExists , pathToModule ) ;
15821633 } ) ;
15831634 it ( `should have ${ appName } /src/${ scriptsFolder } /${ pack } /component.json` , ( ) => {
15841635 const pathToComponentJson = util . getAppDir ( path . join (
@@ -2829,6 +2880,34 @@ describe('Component & Jet Pack Tests', () => {
28292880 } )
28302881 }
28312882 }
2883+ it ( `should be built in ${ appName } /web/js/jet-composites/${ pack } when unversioned is set to true in oraclejetconfig file` , async ( ) => {
2884+ const appDir = util . getAppDir ( appName ) ;
2885+ const { pathToApp } = util . getAppPathData ( appName , scriptsFolder ) ;
2886+ const builtUnversionedPackPath = path . join ( pathToApp , 'web' , 'js' , 'jet-composites' , pack ) ;
2887+ let oracleJetConfigJson = fs . readJSONSync ( path . join ( pathToApp , 'oraclejetconfig.json' ) ) ;
2888+ // Modify the oraclejetconfig json:
2889+ oracleJetConfigJson . unversioned = true ;
2890+ // Re-write the json:
2891+ fs . writeJSONSync ( path . join ( pathToApp , 'oraclejetconfig.json' ) , oracleJetConfigJson , { deference : true } ) ;
2892+ await util . execCmd ( `${ util . OJET_APP_COMMAND } build component ${ pack } ` , {
2893+ cwd : appDir
2894+ } , true , true ) ;
2895+ assert . ok ( fs . existsSync ( builtUnversionedPackPath ) , `${ pack } has a versioned path in the staging folder` ) ;
2896+ } ) ;
2897+ it ( `should be built in ${ appName } /web/js/jet-composites/${ pack } /${ DEFAULT_PACK_VERSION } when unversioned is set to false in oraclejetconfig file` , async ( ) => {
2898+ const appDir = util . getAppDir ( appName ) ;
2899+ const { pathToApp } = util . getAppPathData ( appName , scriptsFolder ) ;
2900+ const builtVersionedPackPath = path . join ( pathToApp , 'web' , 'js' , 'jet-composites' , pack , DEFAULT_PACK_VERSION ) ;
2901+ let oracleJetConfigJson = fs . readJSONSync ( path . join ( pathToApp , 'oraclejetconfig.json' ) ) ;
2902+ // Modify the oraclejetconfig json:
2903+ oracleJetConfigJson . unversioned = false ;
2904+ // Re-write the json:
2905+ fs . writeJSONSync ( path . join ( pathToApp , 'oraclejetconfig.json' ) , oracleJetConfigJson , { deference : true } ) ;
2906+ await util . execCmd ( `${ util . OJET_APP_COMMAND } build component ${ pack } ` , {
2907+ cwd : appDir
2908+ } , true , true ) ;
2909+ assert . ok ( fs . existsSync ( builtVersionedPackPath ) , `${ pack } has an unversioned path in the staging folder` ) ;
2910+ } ) ;
28322911 } )
28332912 }
28342913
@@ -3370,31 +3449,31 @@ function doNotOverWriteOjCPathMappingTest({
33703449 } ) ;
33713450 } ) ;
33723451
3373- describe ( 'ojet build, do not overwrite path-mapping for oj-c' , ( ) => {
3374- util . runComponentTestInAllTestApps ( {
3375- test : doNotOverWriteOjCPathMappingTest
3376- } ) ;
3377- } ) ;
3378-
3379- describe ( 'ojet build --release, do not overwrite path-mapping for oj-c' , ( ) => {
3380- util . runComponentTestInAllTestApps ( {
3381- test : doNotOverWriteOjCPathMappingTest ,
3382- buildType : 'release'
3383- } )
3384- } )
3385-
3386- describe ( 'ojet build, do not overwrite path-mapping for oj-c' , ( ) => {
3387- util . runComponentTestInAllTestApps ( {
3388- test : doNotOverWriteOjCPathMappingTest
3389- } ) ;
3390- } ) ;
3391-
3392- describe ( 'ojet build --release, do not overwrite path-mapping for oj-c' , ( ) => {
3393- util . runComponentTestInAllTestApps ( {
3394- test : doNotOverWriteOjCPathMappingTest ,
3395- buildType : 'release'
3396- } ) ;
3397- } ) ;
3452+ // describe('ojet build, do not overwrite path-mapping for oj-c', () => {
3453+ // util.runComponentTestInAllTestApps({
3454+ // test: doNotOverWriteOjCPathMappingTest
3455+ // });
3456+ // });
3457+
3458+ // describe('ojet build --release, do not overwrite path-mapping for oj-c', () => {
3459+ // util.runComponentTestInAllTestApps({
3460+ // test: doNotOverWriteOjCPathMappingTest,
3461+ // buildType: 'release'
3462+ // })
3463+ // })
3464+
3465+ // describe('ojet build, do not overwrite path-mapping for oj-c', () => {
3466+ // util.runComponentTestInAllTestApps({
3467+ // test: doNotOverWriteOjCPathMappingTest
3468+ // });
3469+ // });
3470+
3471+ // describe('ojet build --release, do not overwrite path-mapping for oj-c', () => {
3472+ // util.runComponentTestInAllTestApps({
3473+ // test: doNotOverWriteOjCPathMappingTest,
3474+ // buildType: 'release'
3475+ // });
3476+ // });
33983477
33993478 describe ( 'ojet build, map local reference pack in main.js test' , ( ) => {
34003479 util . runComponentTestInAllTestApps ( {
0 commit comments