@@ -59,6 +59,31 @@ describe('Lightning component creation tests:', () => {
59
59
) ;
60
60
}
61
61
) ;
62
+
63
+ test
64
+ . withOrg ( )
65
+ . withProject ( )
66
+ . stdout ( )
67
+ . command ( [
68
+ 'force:lightning:component:create' ,
69
+ '--componentname' ,
70
+ 'foo' ,
71
+ '--outputdir' ,
72
+ 'aura' ,
73
+ '--template' ,
74
+ 'default'
75
+ ] )
76
+ . it (
77
+ 'should create lightning aura component files from default template in the aura output directory' ,
78
+ ctx => {
79
+ assert . file ( AuraLightningTestFormatter . fileformatter ( 'foo' , 'foo' ) ) ;
80
+ assert . file ( path . join ( 'aura' , 'foo' , 'foo.cmp-meta.xml' ) ) ;
81
+ assert . fileContent (
82
+ path . join ( 'aura' , 'foo' , 'foo.cmp-meta.xml' ) ,
83
+ '<AuraDefinitionBundle xmlns="http://soap.sforce.com/2006/04/metadata">'
84
+ ) ;
85
+ }
86
+ ) ;
62
87
} ) ;
63
88
64
89
describe ( 'Check lightning aura components creation without -meta.xml file' , ( ) => {
@@ -112,12 +137,12 @@ describe('Lightning component creation tests:', () => {
112
137
. it (
113
138
'should create lightning web component files in the lwc output directory with the internal flag for disabling -meta.xml files' ,
114
139
ctx => {
115
- assert . file (
116
- path . join ( 'lwc' , 'internallwctest' , 'internallwctest.html' )
117
- ) ;
118
140
assert . noFile (
119
141
path . join ( 'lwc' , 'internallwctest' , 'internallwctest.js-meta.xml' )
120
142
) ;
143
+ assert . file (
144
+ path . join ( 'lwc' , 'internallwctest' , 'internallwctest.html' )
145
+ ) ;
121
146
assert . file (
122
147
path . join ( 'lwc' , 'internallwctest' , 'internallwctest.js' )
123
148
) ;
@@ -144,9 +169,119 @@ describe('Lightning component creation tests:', () => {
144
169
'lwc'
145
170
] )
146
171
. it (
147
- 'should create lightning web component files in the lwc output directory with the internal flag for disabling -meta.xml files ' ,
172
+ 'should create lightning web component files in the lwc output directory' ,
148
173
ctx => {
149
174
assert . file ( path . join ( 'lwc' , 'foo' , 'foo.js-meta.xml' ) ) ;
175
+ assert . file ( path . join ( 'lwc' , 'foo' , 'foo.html' ) ) ;
176
+ assert . file ( path . join ( 'lwc' , 'foo' , 'foo.js' ) ) ;
177
+ assert . fileContent (
178
+ path . join ( 'lwc' , 'foo' , 'foo.js' ) ,
179
+ 'export default class Foo extends LightningElement {}'
180
+ ) ;
181
+ }
182
+ ) ;
183
+
184
+ test
185
+ . withOrg ( )
186
+ . withProject ( )
187
+ . stdout ( )
188
+ . command ( [
189
+ 'force:lightning:component:create' ,
190
+ '--componentname' ,
191
+ 'foo' ,
192
+ '--outputdir' ,
193
+ 'lwc' ,
194
+ '--type' ,
195
+ 'lwc' ,
196
+ '--template' ,
197
+ 'default'
198
+ ] )
199
+ . it (
200
+ 'should create lightning web component files from default template in the lwc output directory' ,
201
+ ctx => {
202
+ assert . file ( path . join ( 'lwc' , 'foo' , 'foo.js-meta.xml' ) ) ;
203
+ assert . file ( path . join ( 'lwc' , 'foo' , 'foo.html' ) ) ;
204
+ assert . file ( path . join ( 'lwc' , 'foo' , 'foo.js' ) ) ;
205
+ assert . fileContent (
206
+ path . join ( 'lwc' , 'foo' , 'foo.js' ) ,
207
+ 'export default class Foo extends LightningElement {}'
208
+ ) ;
209
+ }
210
+ ) ;
211
+ } ) ;
212
+
213
+ describe ( 'Check analytics dashboard lwc creation' , ( ) => {
214
+ test
215
+ . withOrg ( )
216
+ . withProject ( )
217
+ . stdout ( )
218
+ . command ( [
219
+ 'force:lightning:component:create' ,
220
+ '--componentname' ,
221
+ 'foo' ,
222
+ '--outputdir' ,
223
+ 'lwc' ,
224
+ '--type' ,
225
+ 'lwc' ,
226
+ '--template' ,
227
+ 'analyticsDashboard'
228
+ ] )
229
+ . it (
230
+ 'should create analyticsDashboard lwc files in the lwc output directory' ,
231
+ ctx => {
232
+ const jsFile = path . join ( 'lwc' , 'foo' , 'foo.js' ) ;
233
+ const metaFile = path . join ( 'lwc' , 'foo' , 'foo.js-meta.xml' ) ;
234
+ assert . file ( metaFile ) ;
235
+ assert . file ( path . join ( 'lwc' , 'foo' , 'foo.html' ) ) ;
236
+ assert . file ( jsFile ) ;
237
+ assert . fileContent ( metaFile , '<target>analytics__Dashboard</target>' ) ;
238
+ assert . fileContent ( metaFile , 'targets="analytics__Dashboard"' ) ;
239
+ assert . fileContent ( metaFile , '<hasStep>false</hasStep>' ) ;
240
+ assert . fileContent (
241
+ jsFile ,
242
+ 'export default class Foo extends LightningElement {'
243
+ ) ;
244
+ assert . fileContent ( jsFile , '@api getState;' ) ;
245
+ assert . fileContent ( jsFile , '@api setState;' ) ;
246
+ }
247
+ ) ;
248
+ test
249
+ . withOrg ( )
250
+ . withProject ( )
251
+ . stdout ( )
252
+ . command ( [
253
+ 'force:lightning:component:create' ,
254
+ '--componentname' ,
255
+ 'foo' ,
256
+ '--outputdir' ,
257
+ 'lwc' ,
258
+ '--type' ,
259
+ 'lwc' ,
260
+ '--template' ,
261
+ 'analyticsDashboardWithStep'
262
+ ] )
263
+ . it (
264
+ 'should create analyticsDashboardWithStep lwc files in the lwc output directory' ,
265
+ ctx => {
266
+ const jsFile = path . join ( 'lwc' , 'foo' , 'foo.js' ) ;
267
+ const metaFile = path . join ( 'lwc' , 'foo' , 'foo.js-meta.xml' ) ;
268
+ assert . file ( metaFile ) ;
269
+ assert . file ( path . join ( 'lwc' , 'foo' , 'foo.html' ) ) ;
270
+ assert . file ( jsFile ) ;
271
+ assert . fileContent ( metaFile , '<target>analytics__Dashboard</target>' ) ;
272
+ assert . fileContent ( metaFile , 'targets="analytics__Dashboard"' ) ;
273
+ assert . fileContent ( metaFile , '<hasStep>true</hasStep>' ) ;
274
+ assert . fileContent (
275
+ jsFile ,
276
+ 'export default class Foo extends LightningElement {'
277
+ ) ;
278
+ assert . fileContent ( jsFile , '@api getState;' ) ;
279
+ assert . fileContent ( jsFile , '@api setState;' ) ;
280
+ assert . fileContent ( jsFile , '@api results;' ) ;
281
+ assert . fileContent ( jsFile , '@api metadata;' ) ;
282
+ assert . fileContent ( jsFile , '@api selection;' ) ;
283
+ assert . fileContent ( jsFile , '@api setSelection;' ) ;
284
+ assert . fileContent ( jsFile , '@api selectMode;' ) ;
150
285
}
151
286
) ;
152
287
} ) ;
@@ -184,5 +319,46 @@ describe('Lightning component creation tests:', () => {
184
319
. it ( 'should throw missing lwc parent folder error' , ctx => {
185
320
expect ( ctx . stderr ) . to . contain ( messages . getMessage ( 'MissingLWCFolder' ) ) ;
186
321
} ) ;
322
+ test
323
+ . withOrg ( )
324
+ . withProject ( )
325
+ . stderr ( )
326
+ . command ( [
327
+ 'force:lightning:component:create' ,
328
+ '--outputdir' ,
329
+ 'lwc' ,
330
+ '--componentname' ,
331
+ 'foo' ,
332
+ '--type' ,
333
+ 'lwc' ,
334
+ '--template' ,
335
+ 'foo'
336
+ ] )
337
+ . it ( 'should throw invalid template error' , ctx => {
338
+ expect ( ctx . stderr ) . to . contain ( messages . getMessage ( 'InvalidTemplate' ) ) ;
339
+ } ) ;
340
+ test
341
+ . withOrg ( )
342
+ . withProject ( )
343
+ . stderr ( )
344
+ . command ( [
345
+ 'force:lightning:component:create' ,
346
+ '--outputdir' ,
347
+ 'aura' ,
348
+ '--componentname' ,
349
+ 'foo' ,
350
+ '--type' ,
351
+ 'aura' ,
352
+ '--template' ,
353
+ 'analyticsDashboard'
354
+ ] )
355
+ . it ( 'should throw missing template error' , ctx => {
356
+ expect ( ctx . stderr ) . to . contain (
357
+ messages . getMessage ( 'MissingLightningComponentTemplate' , [
358
+ 'analyticsDashboard' ,
359
+ 'aura'
360
+ ] )
361
+ ) ;
362
+ } ) ;
187
363
} ) ;
188
364
} ) ;
0 commit comments