@@ -2,7 +2,7 @@ import { filterArgumentsForCordova, generateOptionsForCordovaBuild } from '../ut
2
2
3
3
describe ( '@ionic/cli-utils' , ( ) => {
4
4
5
- const metadata = {
5
+ const buildMetadata = {
6
6
name : 'build' ,
7
7
inputs : [
8
8
{
@@ -37,38 +37,63 @@ describe('@ionic/cli-utils', () => {
37
37
]
38
38
} ;
39
39
40
+ const platformMetadata = {
41
+ name : 'platform' ,
42
+ inputs : [
43
+ {
44
+ name : 'action' ,
45
+ } ,
46
+ {
47
+ name : 'platform' ,
48
+ }
49
+ ] ,
50
+ options : [
51
+ {
52
+ name : 'boolopt' ,
53
+ type : Boolean ,
54
+ default : false ,
55
+ } ,
56
+ ]
57
+ } ;
58
+
40
59
describe ( 'filterArgumentsForCordova' , ( ) => {
41
60
42
61
it ( 'should return the command name and inputs if no options passed' , ( ) => {
43
62
const options = { _ : [ 'ios' ] , boolopt : false , cdvopt1 : null , cdvopt2 : false , prod : true , optimizejs : true } ;
44
- const result = filterArgumentsForCordova ( metadata , options ) ;
63
+ const result = filterArgumentsForCordova ( buildMetadata , options ) ;
45
64
expect ( result ) . toEqual ( [ 'build' , 'ios' ] ) ;
46
65
} ) ;
47
66
48
67
it ( 'should only include options with the Cordova intent' , ( ) => {
49
68
const options = { _ : [ 'ios' ] , boolopt : true , cdvopt1 : 'foo' , cdvopt2 : true , prod : true , optimizejs : true } ;
50
- const result = filterArgumentsForCordova ( metadata , options ) ;
69
+ const result = filterArgumentsForCordova ( buildMetadata , options ) ;
51
70
expect ( result ) . toEqual ( [ 'build' , 'ios' , '--cdvopt1' , 'foo' , '--cdvopt2' ] ) ;
52
71
} ) ;
53
72
54
73
it ( 'should include --verbose' , ( ) => {
55
74
const options = { _ : [ 'ios' ] , boolopt : true , cdvopt1 : 'foo' , cdvopt2 : true , prod : true , optimizejs : true , verbose : true } ;
56
- const result = filterArgumentsForCordova ( metadata , options ) ;
75
+ const result = filterArgumentsForCordova ( buildMetadata , options ) ;
57
76
expect ( result ) . toEqual ( [ 'build' , 'ios' , '--cdvopt1' , 'foo' , '--cdvopt2' , '--verbose' ] ) ;
58
77
} ) ;
59
78
60
79
it ( 'should include additional options' , ( ) => {
61
80
const options = { _ : [ 'android' ] , '--' : [ '--someopt' ] , boolopt : true , cdvopt1 : 'foo' , cdvopt2 : true , prod : true , optimizejs : true } ;
62
- const result = filterArgumentsForCordova ( metadata , options ) ;
81
+ const result = filterArgumentsForCordova ( buildMetadata , options ) ;
63
82
expect ( result ) . toEqual ( [ 'build' , 'android' , '--cdvopt1' , 'foo' , '--cdvopt2' , '--someopt' ] ) ;
64
83
} ) ;
65
84
66
85
it ( 'should include additional and unparsed options' , ( ) => {
67
86
const options = { _ : [ 'android' ] , '--' : [ '--someopt' , '--' , '--gradleArg=-PcdvBuildMultipleApks=true' ] , boolopt : true , cdvopt1 : 'foo' , cdvopt2 : true , prod : true , optimizejs : true } ;
68
- const result = filterArgumentsForCordova ( metadata , options ) ;
87
+ const result = filterArgumentsForCordova ( buildMetadata , options ) ;
69
88
expect ( result ) . toEqual ( [ 'build' , 'android' , '--cdvopt1' , 'foo' , '--cdvopt2' , '--someopt' , '--' , '--gradleArg=-PcdvBuildMultipleApks=true' ] ) ;
70
89
} ) ;
71
90
91
+ it ( 'should respect --nosave' , ( ) => {
92
+ const options = { _ : [ 'add' , 'android' ] , '--' : [ ] , nosave : true } ;
93
+ const result = filterArgumentsForCordova ( platformMetadata , options ) ;
94
+ expect ( result ) . toEqual ( [ 'platform' , 'add' , 'android' , '--nosave' ] ) ;
95
+ } ) ;
96
+
72
97
} ) ;
73
98
74
99
describe ( 'generateOptionsForCordovaBuild' , ( ) => {
@@ -77,15 +102,15 @@ describe('@ionic/cli-utils', () => {
77
102
const inputs = [ 'ios' ] ;
78
103
const options = { _ : [ ] } ;
79
104
80
- const result = generateOptionsForCordovaBuild ( metadata , inputs , options ) ;
105
+ const result = generateOptionsForCordovaBuild ( buildMetadata , inputs , options ) ;
81
106
expect ( result ) . toEqual ( { '_' : [ ] , externalAddressRequired : true , nobrowser : true , engine : 'cordova' , platform : 'ios' } ) ;
82
107
} ) ;
83
108
84
109
it ( 'should include the options with app-scripts group or no group, but not cordova group' , ( ) => {
85
110
const inputs = [ 'ios' ] ;
86
111
const options = { _ : [ ] , boolopt : false , cdvopt1 : null , cdvopt2 : false , prod : true , optimizejs : true } ;
87
112
88
- const result = generateOptionsForCordovaBuild ( metadata , inputs , options ) ;
113
+ const result = generateOptionsForCordovaBuild ( buildMetadata , inputs , options ) ;
89
114
expect ( result ) . toEqual ( { '_' : [ ] , boolopt : false , externalAddressRequired : true , nobrowser : true , engine : 'cordova' , platform : 'ios' , prod : true , optimizejs : true } ) ;
90
115
} ) ;
91
116
0 commit comments