@@ -84,41 +84,97 @@ describe('ionic', () => {
8484 } ;
8585
8686 it ( 'should pass options' , async ( ) => {
87- const root = 'fakeRoot' ;
88- const project = {
89- requireIntegration : jest . fn ( ( ) => ( { root } ) ) ,
90- } ;
91- const runner = new AngularServeCLI ( { project } as any ) ;
87+ const project = { } ;
88+ const cli = new AngularServeCLI ( { project } as any ) ;
9289 const options = {
9390 ...defaults ,
91+ address : 'localhost' ,
92+ port : 4200 ,
9493 sourcemaps : true ,
9594 ssl : true ,
9695 } ;
9796
98- const result = await ( runner as any ) . serveOptionsToNgArgs ( options ) ;
99- expect ( result ) . toEqual ( expect . arrayContaining ( [
100- `--ssl` ,
97+ const result = await ( cli as any ) . serveOptionsToNgArgs ( options ) ;
98+ expect ( result ) . toEqual ( [
99+ `--host=${ options . address } ` ,
100+ `--port=${ options . port } ` ,
101101 `--source-map` ,
102- ] ) ) ;
102+ `--ssl` ,
103+ ] ) ;
103104 } ) ;
104105
105106 it ( 'should pass cordova options' , async ( ) => {
106107 const root = 'fakeRoot' ;
107108 const project = {
108109 requireIntegration : jest . fn ( ( ) => ( { root } ) ) ,
109110 } ;
110- const runner = new AngularServeCLI ( { project } as any ) ;
111+ const cli = new AngularServeCLI ( { project } as any ) ;
111112 const options = {
112113 ...defaults ,
113114 engine : 'cordova' ,
114115 platform : 'fakePlatform' ,
115116 } ;
116117
117- const result = await ( runner as any ) . serveOptionsToNgArgs ( options ) ;
118- expect ( result ) . toEqual ( expect . arrayContaining ( [
118+ const result = await ( cli as any ) . serveOptionsToNgArgs ( options ) ;
119+ expect ( result ) . toEqual ( [
119120 `--platform=${ options . platform } ` ,
120121 `--cordova-base-path=${ root } ` ,
121- ] ) ) ;
122+ ] ) ;
123+ } ) ;
124+
125+ it ( 'should pass separated options' , async ( ) => {
126+ const project = { } ;
127+ const cli = new AngularServeCLI ( { project } as any ) ;
128+ const options = {
129+ ...defaults ,
130+ '--' : [ '--extra=true' ] ,
131+ } ;
132+
133+ const result = await ( cli as any ) . serveOptionsToNgArgs ( options ) ;
134+ expect ( result ) . toEqual ( [ '--extra=true' ] ) ;
135+ } ) ;
136+
137+ it ( 'should not pass separated options for cordova' , async ( ) => {
138+ const root = 'fakeRoot' ;
139+ const project = {
140+ requireIntegration : jest . fn ( ( ) => ( { root } ) ) ,
141+ } ;
142+ const cli = new AngularServeCLI ( { project } as any ) ;
143+ const options = {
144+ ...defaults ,
145+ engine : 'cordova' ,
146+ platform : 'fakePlatform' ,
147+ '--' : [ '--extra=true' ] ,
148+ } ;
149+
150+ const result = await ( cli as any ) . serveOptionsToNgArgs ( options ) ;
151+ expect ( result ) . not . toEqual ( expect . arrayContaining ( [ '--extra=true' ] ) ) ;
152+ } ) ;
153+
154+ it ( 'should pass configuration and project for custom program' , async ( ) => {
155+ const project = { } ;
156+ const cli = new AngularServeCLI ( { project } as any ) ;
157+ ( cli as any ) . _resolvedProgram = 'npm' ;
158+ const options = {
159+ ...defaults ,
160+ configuration : 'production' ,
161+ project : 'otherProject' ,
162+ } ;
163+
164+ const result = await ( cli as any ) . serveOptionsToNgArgs ( options ) ;
165+ expect ( result ) . toEqual ( [ '--configuration=production' , '--project=otherProject' ] ) ;
166+ } ) ;
167+
168+ it ( 'should not pass configuration and project for custom program if they are the defaults' , async ( ) => {
169+ const project = { } ;
170+ const cli = new AngularServeCLI ( { project } as any ) ;
171+ ( cli as any ) . _resolvedProgram = 'npm' ;
172+ const options = {
173+ ...defaults ,
174+ } ;
175+
176+ const result = await ( cli as any ) . serveOptionsToNgArgs ( options ) ;
177+ expect ( result ) . toEqual ( [ ] ) ;
122178 } ) ;
123179
124180 } ) ;
0 commit comments