@@ -273,6 +273,77 @@ describe('previewUtils', () => {
273273 expect ( parsed . values [ 'target-org' ] ) . to . be . undefined ;
274274 } ) ;
275275
276+ it ( 'generateComponentPreviewLaunchArguments with performance mode enabled' , async ( ) => {
277+ const result = PreviewUtils . generateComponentPreviewLaunchArguments (
278+ 'https://localhost:3333' ,
279+ testLdpServerId ,
280+ 'myTestComponent' ,
281+ 'myTargetOrg' ,
282+ true
283+ ) ;
284+
285+ const parsed = parseArgs ( {
286+ args : result ,
287+ options : {
288+ path : { type : 'string' } ,
289+ 'target-org' : { type : 'string' } ,
290+ } ,
291+ } ) ;
292+
293+ expect ( parsed . values . path ) . to . include ( 'ldpServerUrl=https://localhost:3333' ) ;
294+ expect ( parsed . values . path ) . to . include ( `ldpServerId=${ testLdpServerId } ` ) ;
295+ expect ( parsed . values . path ) . to . include ( 'specifier=c/myTestComponent' ) ;
296+ expect ( parsed . values . path ) . to . include ( 'mode=performance' ) ;
297+ expect ( parsed . values [ 'target-org' ] ) . to . equal ( 'myTargetOrg' ) ;
298+ } ) ;
299+
300+ it ( 'generateComponentPreviewLaunchArguments with performance mode disabled' , async ( ) => {
301+ const result = PreviewUtils . generateComponentPreviewLaunchArguments (
302+ 'https://localhost:3333' ,
303+ testLdpServerId ,
304+ 'myTestComponent' ,
305+ 'myTargetOrg' ,
306+ false
307+ ) ;
308+
309+ const parsed = parseArgs ( {
310+ args : result ,
311+ options : {
312+ path : { type : 'string' } ,
313+ 'target-org' : { type : 'string' } ,
314+ } ,
315+ } ) ;
316+
317+ expect ( parsed . values . path ) . to . include ( 'ldpServerUrl=https://localhost:3333' ) ;
318+ expect ( parsed . values . path ) . to . include ( `ldpServerId=${ testLdpServerId } ` ) ;
319+ expect ( parsed . values . path ) . to . include ( 'specifier=c/myTestComponent' ) ;
320+ expect ( parsed . values . path ) . to . not . include ( 'mode=performance' ) ;
321+ expect ( parsed . values [ 'target-org' ] ) . to . equal ( 'myTargetOrg' ) ;
322+ } ) ;
323+
324+ it ( 'generateComponentPreviewLaunchArguments with performance mode undefined (default)' , async ( ) => {
325+ const result = PreviewUtils . generateComponentPreviewLaunchArguments (
326+ 'https://localhost:3333' ,
327+ testLdpServerId ,
328+ 'myTestComponent' ,
329+ 'myTargetOrg'
330+ ) ;
331+
332+ const parsed = parseArgs ( {
333+ args : result ,
334+ options : {
335+ path : { type : 'string' } ,
336+ 'target-org' : { type : 'string' } ,
337+ } ,
338+ } ) ;
339+
340+ expect ( parsed . values . path ) . to . include ( 'ldpServerUrl=https://localhost:3333' ) ;
341+ expect ( parsed . values . path ) . to . include ( `ldpServerId=${ testLdpServerId } ` ) ;
342+ expect ( parsed . values . path ) . to . include ( 'specifier=c/myTestComponent' ) ;
343+ expect ( parsed . values . path ) . to . not . include ( 'mode=performance' ) ;
344+ expect ( parsed . values [ 'target-org' ] ) . to . equal ( 'myTargetOrg' ) ;
345+ } ) ;
346+
276347 it ( 'getTargetOrgFromArguments finds -o flag' , async ( ) => {
277348 const args = [ 'command' , '-o' , 'myOrg' , 'otherArg' ] ;
278349 const result = PreviewUtils . getTargetOrgFromArguments ( args ) ;
0 commit comments