@ihk-gfi/lux-components-update 11.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/LICENSE +198 -0
  2. package/README.md +55 -0
  3. package/package.json +54 -0
  4. package/src/add-lux-components/files/app/app-routing.module.ts +19 -0
  5. package/src/add-lux-components/files/app/app.component.html +27 -0
  6. package/src/add-lux-components/files/app/app.component.spec.ts +19 -0
  7. package/src/add-lux-components/files/app/app.component.ts +13 -0
  8. package/src/add-lux-components/files/app/app.module.ts +56 -0
  9. package/src/add-lux-components/files/app/error/error.component.html +10 -0
  10. package/src/add-lux-components/files/app/error/error.component.scss +3 -0
  11. package/src/add-lux-components/files/app/error/error.component.spec.ts +49 -0
  12. package/src/add-lux-components/files/app/error/error.component.ts +17 -0
  13. package/src/add-lux-components/files/app/home/home.component.html +7 -0
  14. package/src/add-lux-components/files/app/home/home.component.scss +0 -0
  15. package/src/add-lux-components/files/app/home/home.component.ts +13 -0
  16. package/src/add-lux-components/files/app/profil/profil.component.html +1 -0
  17. package/src/add-lux-components/files/app/profil/profil.component.scss +0 -0
  18. package/src/add-lux-components/files/app/profil/profil.component.spec.ts +24 -0
  19. package/src/add-lux-components/files/app/profil/profil.component.ts +11 -0
  20. package/src/add-lux-components/files/environments/environment.prod.ts +4 -0
  21. package/src/add-lux-components/files/environments/environment.ts +17 -0
  22. package/src/add-lux-components/files/locale/messages.en.xlf +948 -0
  23. package/src/add-lux-components/files/locale/messages.xlf +822 -0
  24. package/src/add-lux-components/files/scripts/.browserslistrc +17 -0
  25. package/src/add-lux-components/files/src/polyfills.ts +68 -0
  26. package/src/add-lux-components/index.d.ts +10 -0
  27. package/src/add-lux-components/index.js +143 -0
  28. package/src/add-lux-components/index.js.map +1 -0
  29. package/src/add-lux-components/index.ts +183 -0
  30. package/src/add-lux-components/index_spec.d.ts +1 -0
  31. package/src/add-lux-components/index_spec.js +51 -0
  32. package/src/add-lux-components/index_spec.js.map +1 -0
  33. package/src/add-lux-components/index_spec.ts +55 -0
  34. package/src/add-lux-components/schema.json +23 -0
  35. package/src/collection.json +55 -0
  36. package/src/migrate-to-eslint/files/.eslintrc.json +68 -0
  37. package/src/migrate-to-eslint/files/.prettierrc +25 -0
  38. package/src/migrate-to-eslint/index.d.ts +6 -0
  39. package/src/migrate-to-eslint/index.js +149 -0
  40. package/src/migrate-to-eslint/index.js.map +1 -0
  41. package/src/migrate-to-eslint/index.ts +181 -0
  42. package/src/migrate-to-eslint/index_spec.d.ts +1 -0
  43. package/src/migrate-to-eslint/index_spec.js +129 -0
  44. package/src/migrate-to-eslint/index_spec.js.map +1 -0
  45. package/src/migrate-to-eslint/index_spec.ts +152 -0
  46. package/src/migrate-to-eslint/schema.json +23 -0
  47. package/src/migrate-to-webcomponent/index.d.ts +10 -0
  48. package/src/migrate-to-webcomponent/index.js +278 -0
  49. package/src/migrate-to-webcomponent/index.js.map +1 -0
  50. package/src/migrate-to-webcomponent/index.ts +331 -0
  51. package/src/migrate-to-webcomponent/index_spec.d.ts +1 -0
  52. package/src/migrate-to-webcomponent/index_spec.js +580 -0
  53. package/src/migrate-to-webcomponent/index_spec.js.map +1 -0
  54. package/src/migrate-to-webcomponent/index_spec.ts +703 -0
  55. package/src/migrate-to-webcomponent/schema.json +23 -0
  56. package/src/update/files/locale/messages.en.xlf +940 -0
  57. package/src/update/files/locale/messages.xlf +815 -0
  58. package/src/update/files/scripts/move-de-files.js +15 -0
  59. package/src/update/index.d.ts +23 -0
  60. package/src/update/index.js +635 -0
  61. package/src/update/index.js.map +1 -0
  62. package/src/update/index.ts +712 -0
  63. package/src/update/index_spec.d.ts +1 -0
  64. package/src/update/index_spec.js +990 -0
  65. package/src/update/index_spec.js.map +1 -0
  66. package/src/update/index_spec.ts +1145 -0
  67. package/src/update/schema.json +23 -0
  68. package/src/update-dependencies/index.d.ts +5 -0
  69. package/src/update-dependencies/index.js +113 -0
  70. package/src/update-dependencies/index.js.map +1 -0
  71. package/src/update-dependencies/index.ts +114 -0
  72. package/src/update-dependencies/schema.json +23 -0
  73. package/src/update110001/index.d.ts +2 -0
  74. package/src/update110001/index.js +42 -0
  75. package/src/update110001/index.js.map +1 -0
  76. package/src/update110001/index.ts +40 -0
  77. package/src/update110001/index_spec.d.ts +1 -0
  78. package/src/update110001/index_spec.js +67 -0
  79. package/src/update110001/index_spec.js.map +1 -0
  80. package/src/update110001/index_spec.ts +72 -0
  81. package/src/update110001/schema.json +23 -0
  82. package/src/update110100/index.d.ts +2 -0
  83. package/src/update110100/index.js +27 -0
  84. package/src/update110100/index.js.map +1 -0
  85. package/src/update110100/index.ts +24 -0
  86. package/src/update110100/index_spec.d.ts +1 -0
  87. package/src/update110100/index_spec.js +69 -0
  88. package/src/update110100/index_spec.js.map +1 -0
  89. package/src/update110100/index_spec.ts +73 -0
  90. package/src/update110100/schema.json +23 -0
  91. package/src/update110101/index.d.ts +2 -0
  92. package/src/update110101/index.js +24 -0
  93. package/src/update110101/index.js.map +1 -0
  94. package/src/update110101/index.ts +21 -0
  95. package/src/update110101/index_spec.d.ts +1 -0
  96. package/src/update110101/index_spec.js +65 -0
  97. package/src/update110101/index_spec.js.map +1 -0
  98. package/src/update110101/index_spec.ts +69 -0
  99. package/src/update110101/schema.json +23 -0
  100. package/src/update110200/index.d.ts +2 -0
  101. package/src/update110200/index.js +24 -0
  102. package/src/update110200/index.js.map +1 -0
  103. package/src/update110200/index.ts +21 -0
  104. package/src/update110200/index_spec.d.ts +1 -0
  105. package/src/update110200/index_spec.js +65 -0
  106. package/src/update110200/index_spec.js.map +1 -0
  107. package/src/update110200/index_spec.ts +69 -0
  108. package/src/update110200/schema.json +23 -0
  109. package/src/update110300/index.d.ts +2 -0
  110. package/src/update110300/index.js +133 -0
  111. package/src/update110300/index.js.map +1 -0
  112. package/src/update110300/index.ts +148 -0
  113. package/src/update110300/index_spec.d.ts +1 -0
  114. package/src/update110300/index_spec.js +121 -0
  115. package/src/update110300/index_spec.js.map +1 -0
  116. package/src/update110300/index_spec.ts +139 -0
  117. package/src/update110300/schema.json +23 -0
  118. package/src/utility/dependencies.d.ts +39 -0
  119. package/src/utility/dependencies.js +96 -0
  120. package/src/utility/dependencies.js.map +1 -0
  121. package/src/utility/dependencies.ts +116 -0
  122. package/src/utility/files.d.ts +60 -0
  123. package/src/utility/files.js +299 -0
  124. package/src/utility/files.js.map +1 -0
  125. package/src/utility/files.ts +355 -0
  126. package/src/utility/html.d.ts +49 -0
  127. package/src/utility/html.js +183 -0
  128. package/src/utility/html.js.map +1 -0
  129. package/src/utility/html.ts +212 -0
  130. package/src/utility/json.d.ts +34 -0
  131. package/src/utility/json.js +70 -0
  132. package/src/utility/json.js.map +1 -0
  133. package/src/utility/json.ts +70 -0
  134. package/src/utility/logging.d.ts +32 -0
  135. package/src/utility/logging.js +82 -0
  136. package/src/utility/logging.js.map +1 -0
  137. package/src/utility/logging.ts +80 -0
  138. package/src/utility/test.d.ts +10 -0
  139. package/src/utility/test.js +24 -0
  140. package/src/utility/test.js.map +1 -0
  141. package/src/utility/test.ts +24 -0
  142. package/src/utility/typescript.d.ts +22 -0
  143. package/src/utility/typescript.js +521 -0
  144. package/src/utility/typescript.js.map +1 -0
  145. package/src/utility/typescript.ts +598 -0
  146. package/src/utility/typescript_spec.d.ts +1 -0
  147. package/src/utility/typescript_spec.js +1006 -0
  148. package/src/utility/typescript_spec.js.map +1 -0
  149. package/src/utility/typescript_spec.ts +1267 -0
  150. package/src/utility/util.d.ts +33 -0
  151. package/src/utility/util.js +139 -0
  152. package/src/utility/util.js.map +1 -0
  153. package/src/utility/util.ts +140 -0
  154. package/src/utility/validation.d.ts +11 -0
  155. package/src/utility/validation.js +44 -0
  156. package/src/utility/validation.js.map +1 -0
  157. package/src/utility/validation.ts +49 -0
  158. package/tsconfig.json +37 -0
@@ -0,0 +1,1267 @@
1
+ import { SchematicContext } from '@angular-devkit/schematics';
2
+ import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
3
+ import * as path from 'path';
4
+ import { appOptions, workspaceOptions } from '../utility/test';
5
+ import { UtilConfig } from '../utility/util';
6
+ import {
7
+ addClassProperty,
8
+ addConstructorContent,
9
+ addImport,
10
+ addInterface,
11
+ removeImport,
12
+ removeInterface,
13
+ removeProvider
14
+ } from './typescript';
15
+
16
+ const collectionPath = path.join(__dirname, '../collection.json');
17
+
18
+ describe('typescript', () => {
19
+ let appTree: UnitTestTree;
20
+ let runner: SchematicTestRunner;
21
+ let context: SchematicContext;
22
+
23
+ const testOptions: any = {};
24
+
25
+ beforeEach(async () => {
26
+ runner = new SchematicTestRunner('schematics', collectionPath);
27
+
28
+ appTree = await runner.runExternalSchematicAsync('@schematics/angular', 'workspace', workspaceOptions).toPromise();
29
+ appTree = await runner
30
+ .runExternalSchematicAsync('@schematics/angular', 'application', appOptions, appTree)
31
+ .toPromise();
32
+
33
+ UtilConfig.defaultWaitMS = 0;
34
+
35
+ testOptions.project = appOptions.name;
36
+ testOptions.path = workspaceOptions.newProjectRoot + '/' + appOptions.name;
37
+ testOptions.verbose = true;
38
+ });
39
+
40
+ describe('[Method] removeProvider', () => {
41
+ it('Sollte den Provider (mehrere Provider - erster Provider) entfernen', (done) => {
42
+ const filePath = testOptions.path + '/src/app/test.component.ts';
43
+
44
+ appTree.create(
45
+ filePath,
46
+ `
47
+ import { environment } from '../environments/environment';
48
+
49
+ @NgModule({
50
+ declarations : [
51
+ AppComponent
52
+ ],
53
+ imports : [
54
+ HttpClientModule,
55
+ ],
56
+ entryComponents: [
57
+ LuxFilePreviewComponent
58
+ ],
59
+ providers : [
60
+ LuxStorageService,
61
+ LuxDialogService,
62
+ DatePipe
63
+ ],
64
+ bootstrap : [
65
+ AppComponent
66
+ ]
67
+ })
68
+ export class AppModule {
69
+ }
70
+
71
+ `
72
+ );
73
+
74
+ removeProvider(appTree, filePath, 'LuxStorageService', false);
75
+
76
+ const content = appTree.read(filePath)?.toString();
77
+ expect(content).toContain('providers : [\n LuxDialogService,\n DatePipe\n ],');
78
+
79
+ done();
80
+ });
81
+
82
+ it('Sollte den Provider (mehrere Provider - mittlerer Provider) entfernen', (done) => {
83
+ const filePath = testOptions.path + '/src/app/test.component.ts';
84
+
85
+ appTree.create(
86
+ filePath,
87
+ `
88
+ import { environment } from '../environments/environment';
89
+
90
+ @NgModule({
91
+ declarations : [
92
+ AppComponent
93
+ ],
94
+ imports : [
95
+ HttpClientModule,
96
+ ],
97
+ entryComponents: [
98
+ LuxFilePreviewComponent
99
+ ],
100
+ providers : [
101
+ LuxDialogService,
102
+ LuxStorageService,
103
+ DatePipe
104
+ ],
105
+ bootstrap : [
106
+ AppComponent
107
+ ]
108
+ })
109
+ export class AppModule {
110
+ }
111
+
112
+ `
113
+ );
114
+
115
+ removeProvider(appTree, filePath, 'LuxStorageService', false);
116
+
117
+ const content = appTree.read(filePath)?.toString();
118
+ expect(content).toContain('providers : [\n LuxDialogService,\n DatePipe\n ],');
119
+
120
+ done();
121
+ });
122
+
123
+ it('Sollte den Provider (mehrere Provider - mittlerer Provider - komplexer Provider) entfernen', (done) => {
124
+ const filePath = testOptions.path + '/src/app/test.component.ts';
125
+
126
+ appTree.create(
127
+ filePath,
128
+ `
129
+ import { environment } from '../environments/environment';
130
+
131
+ @NgModule({
132
+ declarations : [
133
+ AppComponent
134
+ ],
135
+ imports : [
136
+ HttpClientModule,
137
+ ],
138
+ entryComponents: [
139
+ LuxFilePreviewComponent
140
+ ],
141
+ providers : [
142
+ LuxDialogService,
143
+ {
144
+ provide : HTTP_INTERCEPTORS,
145
+ useClass: UnauthorizedInterceptor,
146
+ multi : true
147
+ },
148
+ DatePipe
149
+ ],
150
+ bootstrap : [
151
+ AppComponent
152
+ ]
153
+ })
154
+ export class AppModule {
155
+ }
156
+
157
+ `
158
+ );
159
+
160
+ removeProvider(appTree, filePath, 'HTTP_INTERCEPTORS', false);
161
+
162
+ const content = appTree.read(filePath)?.toString();
163
+ expect(content).toContain('providers : [\n LuxDialogService,\n DatePipe\n ],');
164
+
165
+ done();
166
+ });
167
+
168
+ it('Sollte den Provider (mehrere Provider - letzter Provider) entfernen', (done) => {
169
+ const filePath = testOptions.path + '/src/app/test.component.ts';
170
+
171
+ appTree.create(
172
+ filePath,
173
+ `
174
+ import { environment } from '../environments/environment';
175
+
176
+ @NgModule({
177
+ declarations : [
178
+ AppComponent
179
+ ],
180
+ imports : [
181
+ HttpClientModule,
182
+ ],
183
+ entryComponents: [
184
+ LuxFilePreviewComponent
185
+ ],
186
+ providers : [
187
+ LuxDialogService,
188
+ DatePipe,
189
+ LuxStorageService
190
+ ],
191
+ bootstrap : [
192
+ AppComponent
193
+ ]
194
+ })
195
+ export class AppModule {
196
+ }
197
+
198
+ `
199
+ );
200
+
201
+ removeProvider(appTree, filePath, 'LuxStorageService', false);
202
+
203
+ const content = appTree.read(filePath)?.toString();
204
+ expect(content).toContain('providers : [\n LuxDialogService,\n DatePipe\n ],');
205
+
206
+ done();
207
+ });
208
+
209
+ it('Sollte den Provider (nicht vorhanden) entfernen', (done) => {
210
+ const filePath = testOptions.path + '/src/app/test.component.ts';
211
+
212
+ appTree.create(
213
+ filePath,
214
+ `
215
+ import { environment } from '../environments/environment';
216
+
217
+ @NgModule({
218
+ declarations : [
219
+ AppComponent
220
+ ],
221
+ imports : [
222
+ HttpClientModule,
223
+ ],
224
+ entryComponents: [
225
+ LuxFilePreviewComponent
226
+ ],
227
+ providers : [
228
+ LuxDialogService,
229
+ DatePipe
230
+ ],
231
+ bootstrap : [
232
+ AppComponent
233
+ ]
234
+ })
235
+ export class AppModule {
236
+ }
237
+
238
+ `
239
+ );
240
+
241
+ removeProvider(appTree, filePath, 'LuxStorageService', false);
242
+
243
+ const content = appTree.read(filePath)?.toString();
244
+ expect(content).toContain('providers : [\n LuxDialogService,\n DatePipe\n ],');
245
+
246
+ done();
247
+ });
248
+
249
+ it('Sollte den Provider (Provider-Abschnitt fehlt vollständig) entfernen', (done) => {
250
+ const filePath = testOptions.path + '/src/app/test.component.ts';
251
+
252
+ appTree.create(
253
+ filePath,
254
+ `
255
+ import { environment } from '../environments/environment';
256
+
257
+ @NgModule({
258
+ declarations : [
259
+ AppComponent
260
+ ],
261
+ imports : [
262
+ HttpClientModule,
263
+ ],
264
+ entryComponents: [
265
+ LuxFilePreviewComponent
266
+ ],
267
+ bootstrap : [
268
+ AppComponent
269
+ ]
270
+ })
271
+ export class AppModule {
272
+ }
273
+
274
+ `
275
+ );
276
+
277
+ removeProvider(appTree, filePath, 'LuxStorageService', false);
278
+
279
+ const content = appTree.read(filePath)?.toString();
280
+ expect(content).not.toContain('providers');
281
+
282
+ done();
283
+ });
284
+
285
+ });
286
+
287
+ describe('[Method] removeInterface', () => {
288
+ it('Sollte das Interface (mehrere Interfaces - erstes Interface) entfernen', (done) => {
289
+ const filePath = testOptions.path + '/src/app/test.component.ts';
290
+
291
+ appTree.create(
292
+ filePath,
293
+ `
294
+ import { OnInit, OnDestroy, Component } from '@angular/core';
295
+
296
+ @Component({
297
+ selector : 'bp-anbindung-lazy',
298
+ templateUrl: './anbindung-lazy.component.html'
299
+ })
300
+ export class AnbindungLazyComponent implements OnInit, OnDestroy {
301
+
302
+ constructor() {
303
+ }
304
+
305
+ ngOnInit() {
306
+ }
307
+
308
+ }
309
+
310
+ `
311
+ );
312
+
313
+ removeInterface(appTree, filePath, 'OnInit', false);
314
+
315
+ const content = appTree.read(filePath)?.toString();
316
+ expect(content).toContain("export class AnbindungLazyComponent implements OnDestroy {");
317
+
318
+ done();
319
+ });
320
+
321
+ it('Sollte das Interface (mehrere Interfaces - mittleres Interface) entfernen', (done) => {
322
+ const filePath = testOptions.path + '/src/app/test.component.ts';
323
+
324
+ appTree.create(
325
+ filePath,
326
+ `
327
+ import { OnChanges, OnInit, OnDestroy, Component } from '@angular/core';
328
+
329
+ @Component({
330
+ selector : 'bp-anbindung-lazy',
331
+ templateUrl: './anbindung-lazy.component.html'
332
+ })
333
+ export class AnbindungLazyComponent implements OnChanges, OnInit, OnDestroy {
334
+
335
+ constructor() {
336
+ }
337
+
338
+ ngOnInit() {
339
+ }
340
+
341
+ }
342
+
343
+ `
344
+ );
345
+
346
+ removeInterface(appTree, filePath, 'OnInit', false);
347
+
348
+ const content = appTree.read(filePath)?.toString();
349
+ expect(content).toContain("export class AnbindungLazyComponent implements OnChanges, OnDestroy {");
350
+
351
+ done();
352
+ });
353
+
354
+ it('Sollte das Interface (mehrere Interfaces - mittleres Interface - mit extends) entfernen', (done) => {
355
+ const filePath = testOptions.path + '/src/app/test.component.ts';
356
+
357
+ appTree.create(
358
+ filePath,
359
+ `
360
+ import { OnChanges, OnInit, OnDestroy, Component } from '@angular/core';
361
+
362
+ @Component({
363
+ selector : 'bp-anbindung-lazy',
364
+ templateUrl: './anbindung-lazy.component.html'
365
+ })
366
+ export class AnbindungLazyComponent extends Aaa implements OnChanges, OnInit, OnDestroy {
367
+
368
+ constructor() {
369
+ }
370
+
371
+ ngOnInit() {
372
+ }
373
+
374
+ }
375
+
376
+ `
377
+ );
378
+
379
+ removeInterface(appTree, filePath, 'OnInit', false);
380
+
381
+ const content = appTree.read(filePath)?.toString();
382
+ expect(content).toContain("export class AnbindungLazyComponent extends Aaa implements OnChanges, OnDestroy {");
383
+
384
+ done();
385
+ });
386
+
387
+ it('Sollte das Interface (mehrere Interfaces - letztes Interface) entfernen', (done) => {
388
+ const filePath = testOptions.path + '/src/app/test.component.ts';
389
+
390
+ appTree.create(
391
+ filePath,
392
+ `
393
+ import { OnChanges, OnInit, OnDestroy, Component } from '@angular/core';
394
+
395
+ @Component({
396
+ selector : 'bp-anbindung-lazy',
397
+ templateUrl: './anbindung-lazy.component.html'
398
+ })
399
+ export class AnbindungLazyComponent implements OnChanges, OnDestroy, OnInit {
400
+
401
+ constructor() {
402
+ }
403
+
404
+ ngOnInit() {
405
+ }
406
+
407
+ }
408
+
409
+ `
410
+ );
411
+
412
+ removeInterface(appTree, filePath, 'OnInit', false);
413
+
414
+ const content = appTree.read(filePath)?.toString();
415
+ expect(content).toContain("export class AnbindungLazyComponent implements OnChanges, OnDestroy {");
416
+
417
+ done();
418
+ });
419
+
420
+ it('Sollte das Interface (nicht vorhanden) entfernen', (done) => {
421
+ const filePath = testOptions.path + '/src/app/test.component.ts';
422
+
423
+ appTree.create(
424
+ filePath,
425
+ `
426
+ import { OnChanges, OnDestroy, Component } from '@angular/core';
427
+
428
+ @Component({
429
+ selector : 'bp-anbindung-lazy',
430
+ templateUrl: './anbindung-lazy.component.html'
431
+ })
432
+ export class AnbindungLazyComponent {
433
+
434
+ constructor() {
435
+ }
436
+
437
+ ngOnInit() {
438
+ }
439
+
440
+ }
441
+
442
+ `
443
+ );
444
+
445
+ removeInterface(appTree, filePath, 'OnInit', false);
446
+
447
+ const content = appTree.read(filePath)?.toString();
448
+ expect(content).toContain("export class AnbindungLazyComponent {");
449
+
450
+ done();
451
+ });
452
+
453
+ });
454
+
455
+ describe('[Method] addInterface', () => {
456
+ it('Sollte das Interface (mit extends - ohne Interface) hinzufügen', (done) => {
457
+ const filePath = testOptions.path + '/src/app/test.component.ts';
458
+
459
+ appTree.create(
460
+ filePath,
461
+ `
462
+ @Component({
463
+ selector : 'bp-anbindung-lazy',
464
+ templateUrl: './anbindung-lazy.component.html'
465
+ })
466
+ export class AnbindungLazyComponent extends Aaa {
467
+
468
+ constructor() {
469
+ }
470
+
471
+ ngOnInit() {
472
+ }
473
+
474
+ }
475
+
476
+ `
477
+ );
478
+
479
+ addInterface(appTree, filePath, 'OnChanges', false);
480
+
481
+ const content = appTree.read(filePath)?.toString();
482
+ expect(content).toContain('export class AnbindungLazyComponent extends Aaa implements OnChanges {');
483
+
484
+ done();
485
+ });
486
+
487
+ it('Sollte das Interface (mit extends - mit Interface) hinzufügen', (done) => {
488
+ const filePath = testOptions.path + '/src/app/test.component.ts';
489
+
490
+ appTree.create(
491
+ filePath,
492
+ `
493
+ @Component({
494
+ selector : 'bp-anbindung-lazy',
495
+ templateUrl: './anbindung-lazy.component.html'
496
+ })
497
+ export class AnbindungLazyComponent extends Aaa implements Bbb {
498
+
499
+ constructor() {
500
+ }
501
+
502
+ ngOnInit() {
503
+ }
504
+
505
+ }
506
+
507
+ `
508
+ );
509
+
510
+ addInterface(appTree, filePath, 'OnChanges', false);
511
+
512
+ const content = appTree.read(filePath)?.toString();
513
+ expect(content).toContain('export class AnbindungLazyComponent extends Aaa implements Bbb, OnChanges {');
514
+
515
+ done();
516
+ });
517
+
518
+ it('Sollte das Interface (ohne extends - ohne Interface) hinzufügen', (done) => {
519
+ const filePath = testOptions.path + '/src/app/test.component.ts';
520
+
521
+ appTree.create(
522
+ filePath,
523
+ `
524
+ @Component({
525
+ selector : 'bp-anbindung-lazy',
526
+ templateUrl: './anbindung-lazy.component.html'
527
+ })
528
+ export class AnbindungLazyComponent {
529
+
530
+ constructor() {
531
+ }
532
+
533
+ ngOnInit() {
534
+ }
535
+
536
+ }
537
+
538
+ `
539
+ );
540
+
541
+ addInterface(appTree, filePath, 'OnChanges', false);
542
+
543
+ const content = appTree.read(filePath)?.toString();
544
+ expect(content).toContain('export class AnbindungLazyComponent implements OnChanges {');
545
+
546
+ done();
547
+ });
548
+
549
+ it('Sollte das Interface (ohne extends - mit Interface) hinzufügen', (done) => {
550
+ const filePath = testOptions.path + '/src/app/test.component.ts';
551
+
552
+ appTree.create(
553
+ filePath,
554
+ `
555
+ @Component({
556
+ selector : 'bp-anbindung-lazy',
557
+ templateUrl: './anbindung-lazy.component.html'
558
+ })
559
+ export class AnbindungLazyComponent implements OnInit {
560
+
561
+ constructor() {
562
+ }
563
+
564
+ ngOnInit() {
565
+ }
566
+
567
+ }
568
+
569
+ `
570
+ );
571
+
572
+ addInterface(appTree, filePath, 'OnChanges', false);
573
+
574
+ const content = appTree.read(filePath)?.toString();
575
+ expect(content).toContain('export class AnbindungLazyComponent implements OnInit, OnChanges {');
576
+
577
+ done();
578
+ });
579
+ });
580
+
581
+ describe('[Method] addImport', () => {
582
+ it('Sollte den Import (kein Import vorhanden) hinzufügen', (done) => {
583
+ const filePath = testOptions.path + '/src/app/test.component.ts';
584
+
585
+ appTree.create(
586
+ filePath,
587
+ `
588
+ @Component({
589
+ selector : 'bp-anbindung-lazy',
590
+ templateUrl: './anbindung-lazy.component.html'
591
+ })
592
+ export class AnbindungLazyComponent implements OnInit {
593
+
594
+ constructor() {
595
+ }
596
+
597
+ ngOnInit() {
598
+ }
599
+
600
+ }
601
+
602
+ `
603
+ );
604
+
605
+ addImport(appTree, filePath, '@angular/core', 'OnChanges', false);
606
+
607
+ const content = appTree.read(filePath)?.toString();
608
+
609
+ expect(content).toContain("import { OnChanges } from '@angular/core';");
610
+
611
+ done();
612
+ });
613
+
614
+ it('Sollte den Import (bereits vorhanden) hinzufügen', (done) => {
615
+ const filePath = testOptions.path + '/src/app/test.component.ts';
616
+
617
+ appTree.create(
618
+ filePath,
619
+ `
620
+ import { OnChanges, OnDestroy, Component } from '@angular/core';
621
+
622
+ @Component({
623
+ selector : 'bp-anbindung-lazy',
624
+ templateUrl: './anbindung-lazy.component.html'
625
+ })
626
+ export class AnbindungLazyComponent implements OnInit {
627
+
628
+ constructor() {
629
+ }
630
+
631
+ ngOnInit() {
632
+ }
633
+
634
+ }
635
+
636
+ `
637
+ );
638
+
639
+ addImport(appTree, filePath, '@angular/core', 'OnChanges', false);
640
+
641
+ const content = appTree.read(filePath)?.toString();
642
+ expect(content).toContain("import { OnChanges, OnDestroy, Component } from '@angular/core';");
643
+
644
+ done();
645
+ });
646
+
647
+ it('Sollte den Import (ein Import) hinzufügen', (done) => {
648
+ const filePath = testOptions.path + '/src/app/test.component.ts';
649
+
650
+ appTree.create(
651
+ filePath,
652
+ `
653
+ import { OnInit } from '@angular/core';
654
+
655
+ @Component({
656
+ selector : 'bp-anbindung-lazy',
657
+ templateUrl: './anbindung-lazy.component.html'
658
+ })
659
+ export class AnbindungLazyComponent implements OnInit {
660
+
661
+ constructor() {
662
+ }
663
+
664
+ ngOnInit() {
665
+ }
666
+
667
+ }
668
+
669
+ `
670
+ );
671
+
672
+ addImport(appTree, filePath, '@angular/core', 'OnChanges', false);
673
+
674
+ const content = appTree.read(filePath)?.toString();
675
+ expect(content).toContain("import { OnInit, OnChanges } from '@angular/core';");
676
+
677
+ done();
678
+ });
679
+
680
+ it('Sollte den Import (mehrere Imports - einfache Anführungszeichen) hinzufügen', (done) => {
681
+ const filePath = testOptions.path + '/src/app/test.component.ts';
682
+
683
+ appTree.create(
684
+ filePath,
685
+ `
686
+ import { OnInit, Component } from '@angular/core';
687
+
688
+ @Component({
689
+ selector : 'bp-anbindung-lazy',
690
+ templateUrl: './anbindung-lazy.component.html'
691
+ })
692
+ export class AnbindungLazyComponent implements OnInit {
693
+
694
+ constructor() {
695
+ }
696
+
697
+ ngOnInit() {
698
+ }
699
+
700
+ }
701
+
702
+ `
703
+ );
704
+
705
+ addImport(appTree, filePath, '@angular/core', 'OnChanges', false);
706
+
707
+ const content = appTree.read(filePath)?.toString();
708
+ expect(content).toContain("import { OnInit, Component, OnChanges } from '@angular/core';");
709
+
710
+ done();
711
+ });
712
+
713
+ it('Sollte den Import (mehrere Imports - doppelte Anführungszeichen) hinzufügen', (done) => {
714
+ const filePath = testOptions.path + '/src/app/test.component.ts';
715
+
716
+ appTree.create(
717
+ filePath,
718
+ `
719
+ import { OnInit, Component } from "@angular/core";
720
+
721
+ @Component({
722
+ selector : 'bp-anbindung-lazy',
723
+ templateUrl: './anbindung-lazy.component.html'
724
+ })
725
+ export class AnbindungLazyComponent implements OnInit {
726
+
727
+ constructor() {
728
+ }
729
+
730
+ ngOnInit() {
731
+ }
732
+
733
+ }
734
+
735
+ `
736
+ );
737
+
738
+ addImport(appTree, filePath, '@angular/core', 'OnChanges', false);
739
+
740
+ const content = appTree.read(filePath)?.toString();
741
+ expect(content).toContain(`import { OnInit, Component, OnChanges } from "@angular/core";`);
742
+
743
+ done();
744
+ });
745
+ });
746
+
747
+ describe('[Method] removeImport', () => {
748
+ it('Sollte den Import (mehrere Imports - erster Import) entfernen', (done) => {
749
+ const filePath = testOptions.path + '/src/app/test.component.ts';
750
+
751
+ appTree.create(
752
+ filePath,
753
+ `
754
+ import { OnInit, Component } from '@angular/core';
755
+
756
+ @Component({
757
+ selector : 'bp-anbindung-lazy',
758
+ templateUrl: './anbindung-lazy.component.html'
759
+ })
760
+ export class AnbindungLazyComponent implements OnInit {
761
+
762
+ constructor() {
763
+ }
764
+
765
+ ngOnInit() {
766
+ }
767
+
768
+ }
769
+
770
+ `
771
+ );
772
+
773
+ removeImport(appTree, filePath, '@angular/core', 'OnInit', false);
774
+
775
+ const content = appTree.read(filePath)?.toString();
776
+ expect(content).toContain("import { Component } from '@angular/core';");
777
+
778
+ done();
779
+ });
780
+
781
+ it('Sollte den Import (mehrere Imports - erster Import - doppelte Anführungszeichen) entfernen', (done) => {
782
+ const filePath = testOptions.path + '/src/app/test.component.ts';
783
+
784
+ appTree.create(
785
+ filePath,
786
+ `
787
+ import { OnInit, Component } from "@angular/core";
788
+
789
+ @Component({
790
+ selector : 'bp-anbindung-lazy',
791
+ templateUrl: './anbindung-lazy.component.html'
792
+ })
793
+ export class AnbindungLazyComponent implements OnInit {
794
+
795
+ constructor() {
796
+ }
797
+
798
+ ngOnInit() {
799
+ }
800
+
801
+ }
802
+
803
+ `
804
+ );
805
+
806
+ removeImport(appTree, filePath, '@angular/core', 'OnInit', false);
807
+
808
+ const content = appTree.read(filePath)?.toString();
809
+ expect(content).toContain(`import { Component } from "@angular/core";`);
810
+
811
+ done();
812
+ });
813
+
814
+ it('Sollte den Import (mehrere Imports - mittlerer Import) entfernen', (done) => {
815
+ const filePath = testOptions.path + '/src/app/test.component.ts';
816
+
817
+ appTree.create(
818
+ filePath,
819
+ `
820
+ import { OnDestroy, OnInit, Component } from '@angular/core';
821
+
822
+ @Component({
823
+ selector : 'bp-anbindung-lazy',
824
+ templateUrl: './anbindung-lazy.component.html'
825
+ })
826
+ export class AnbindungLazyComponent implements OnInit {
827
+
828
+ constructor() {
829
+ }
830
+
831
+ ngOnInit() {
832
+ }
833
+
834
+ }
835
+
836
+ `
837
+ );
838
+
839
+ removeImport(appTree, filePath, '@angular/core', 'OnInit', false);
840
+
841
+ const content = appTree.read(filePath)?.toString();
842
+ expect(content).toContain("import { OnDestroy, Component } from '@angular/core';");
843
+
844
+ done();
845
+ });
846
+
847
+ it('Sollte den Import (mehrere Imports - mittlerer Import - ohne Leerzeichen) entfernen', (done) => {
848
+ const filePath = testOptions.path + '/src/app/test.component.ts';
849
+
850
+ appTree.create(
851
+ filePath,
852
+ `
853
+ import { OnDestroy,OnInit,Component } from '@angular/core';
854
+
855
+ @Component({
856
+ selector : 'bp-anbindung-lazy',
857
+ templateUrl: './anbindung-lazy.component.html'
858
+ })
859
+ export class AnbindungLazyComponent implements OnInit {
860
+
861
+ constructor() {
862
+ }
863
+
864
+ ngOnInit() {
865
+ }
866
+
867
+ }
868
+
869
+ `
870
+ );
871
+
872
+ removeImport(appTree, filePath, '@angular/core', 'OnInit', false);
873
+
874
+ const content = appTree.read(filePath)?.toString();
875
+ expect(content).toContain("import { OnDestroy,Component } from '@angular/core';");
876
+
877
+ done();
878
+ });
879
+
880
+ it('Sollte den Import (mehrere Imports - letzter Import) entfernen', (done) => {
881
+ const filePath = testOptions.path + '/src/app/test.component.ts';
882
+
883
+ appTree.create(
884
+ filePath,
885
+ `
886
+ import { Component, OnInit } from '@angular/core';
887
+
888
+ @Component({
889
+ selector : 'bp-anbindung-lazy',
890
+ templateUrl: './anbindung-lazy.component.html'
891
+ })
892
+ export class AnbindungLazyComponent implements OnInit {
893
+
894
+ constructor() {
895
+ }
896
+
897
+ ngOnInit() {
898
+ }
899
+
900
+ }
901
+
902
+ `
903
+ );
904
+
905
+ removeImport(appTree, filePath, '@angular/core', 'OnInit', false);
906
+
907
+ const content = appTree.read(filePath)?.toString();
908
+ expect(content).toContain("import { Component } from '@angular/core';");
909
+
910
+ done();
911
+ });
912
+
913
+ it('Sollte den Import (nur Paketname) entfernen', (done) => {
914
+ const filePath = testOptions.path + '/src/app/test.component.ts';
915
+
916
+ appTree.create(
917
+ filePath,
918
+ `
919
+ import '@angular/common/locales/global/de';
920
+
921
+ @Component({
922
+ selector : 'bp-anbindung-lazy',
923
+ templateUrl: './anbindung-lazy.component.html'
924
+ })
925
+ export class AnbindungLazyComponent implements OnInit {
926
+
927
+ constructor() {
928
+ }
929
+
930
+ ngOnInit() {
931
+ }
932
+
933
+ }
934
+
935
+ `
936
+ );
937
+
938
+ removeImport(appTree, filePath, '@angular/common/locales/global/de', undefined, false);
939
+
940
+ const content = appTree.read(filePath)?.toString();
941
+ expect(content).not.toContain("import");
942
+
943
+ done();
944
+ });
945
+
946
+ it('Sollte den Import (nur Paketname - nicht vorhanden) entfernen', (done) => {
947
+ const filePath = testOptions.path + '/src/app/test.component.ts';
948
+
949
+ appTree.create(
950
+ filePath,
951
+ `
952
+ import '@angular/common/locales/global/de';
953
+
954
+ @Component({
955
+ selector : 'bp-anbindung-lazy',
956
+ templateUrl: './anbindung-lazy.component.html'
957
+ })
958
+ export class AnbindungLazyComponent implements OnInit {
959
+
960
+ constructor() {
961
+ }
962
+
963
+ ngOnInit() {
964
+ }
965
+
966
+ }
967
+
968
+ `
969
+ );
970
+
971
+ removeImport(appTree, filePath, 'nichtDaAaa', undefined, false);
972
+
973
+ const content = appTree.read(filePath)?.toString();
974
+ expect(content).toContain("import '@angular/common/locales/global/de';");
975
+
976
+ done();
977
+ });
978
+
979
+ it('Sollte den Import (nicht vorhanden) entfernen', (done) => {
980
+ const filePath = testOptions.path + '/src/app/test.component.ts';
981
+
982
+ appTree.create(
983
+ filePath,
984
+ `
985
+ import { Component } from '@angular/core';
986
+
987
+ @Component({
988
+ selector : 'bp-anbindung-lazy',
989
+ templateUrl: './anbindung-lazy.component.html'
990
+ })
991
+ export class AnbindungLazyComponent implements OnInit {
992
+
993
+ constructor() {
994
+ }
995
+
996
+ ngOnInit() {
997
+ }
998
+
999
+ }
1000
+
1001
+ `
1002
+ );
1003
+
1004
+ removeImport(appTree, filePath, '@angular/core', 'OnInit', false);
1005
+
1006
+ const content = appTree.read(filePath)?.toString();
1007
+ expect(content).toContain("import { Component } from '@angular/core';");
1008
+
1009
+ done();
1010
+ });
1011
+
1012
+ });
1013
+
1014
+ describe('[Method] addConstructorContent', () => {
1015
+ it('Sollte Inhalt im Konstruktor (mit Konstruktor - append=false) hinzufügen', (done) => {
1016
+ const filePath = testOptions.path + '/src/app/test.component.ts';
1017
+
1018
+ appTree.create(
1019
+ filePath,
1020
+ `
1021
+ @Component({
1022
+ selector : 'bp-anbindung-lazy',
1023
+ templateUrl: './anbindung-lazy.component.html'
1024
+ })
1025
+ export class AnbindungLazyComponent extends Aaa {
1026
+
1027
+ constructor() {
1028
+ console.log();
1029
+ }
1030
+
1031
+ ngOnInit() {
1032
+ }
1033
+
1034
+ }
1035
+
1036
+ `
1037
+ );
1038
+
1039
+ addConstructorContent(appTree, filePath, 'router.initialNavigation();', false);
1040
+
1041
+ const content = appTree.read(filePath)?.toString();
1042
+ expect(content).toContain('constructor() {\n router.initialNavigation();\n console.log();\n }');
1043
+
1044
+ done();
1045
+ });
1046
+
1047
+ it('Sollte Inhalt im Konstruktor (mit Konstruktor - append=true) hinzufügen', (done) => {
1048
+ const filePath = testOptions.path + '/src/app/test.component.ts';
1049
+
1050
+ appTree.create(
1051
+ filePath,
1052
+ `
1053
+ @Component({
1054
+ selector : 'bp-anbindung-lazy',
1055
+ templateUrl: './anbindung-lazy.component.html'
1056
+ })
1057
+ export class AnbindungLazyComponent extends Aaa {
1058
+
1059
+ constructor() {
1060
+ console.log();
1061
+ }
1062
+
1063
+ ngOnInit() {
1064
+ }
1065
+
1066
+ }
1067
+
1068
+ `
1069
+ );
1070
+
1071
+ addConstructorContent(appTree, filePath, 'router.initialNavigation();', true);
1072
+
1073
+ const content = appTree.read(filePath)?.toString();
1074
+ expect(content).toContain('constructor() {\n console.log();\n router.initialNavigation();\n }');
1075
+
1076
+ done();
1077
+ });
1078
+
1079
+ it('Sollte Inhalt im Konstruktor (mit leerem Konstruktor - append=false) hinzufügen', (done) => {
1080
+ const filePath = testOptions.path + '/src/app/test.component.ts';
1081
+
1082
+ appTree.create(
1083
+ filePath,
1084
+ `
1085
+ @Component({
1086
+ selector : 'bp-anbindung-lazy',
1087
+ templateUrl: './anbindung-lazy.component.html'
1088
+ })
1089
+ export class AnbindungLazyComponent extends Aaa {
1090
+
1091
+ constructor() {}
1092
+
1093
+ ngOnInit() {
1094
+ }
1095
+
1096
+ }
1097
+
1098
+ `
1099
+ );
1100
+
1101
+ addConstructorContent(appTree, filePath, 'router.initialNavigation();', false);
1102
+
1103
+ const content = appTree.read(filePath)?.toString();
1104
+ expect(content).toContain('constructor() {\n router.initialNavigation();\n }');
1105
+
1106
+ done();
1107
+ });
1108
+
1109
+ it('Sollte Inhalt im Konstruktor (mit leerem Konstruktor - append=true) hinzufügen', (done) => {
1110
+ const filePath = testOptions.path + '/src/app/test.component.ts';
1111
+
1112
+ appTree.create(
1113
+ filePath,
1114
+ `
1115
+ @Component({
1116
+ selector : 'bp-anbindung-lazy',
1117
+ templateUrl: './anbindung-lazy.component.html'
1118
+ })
1119
+ export class AnbindungLazyComponent extends Aaa {
1120
+
1121
+ constructor() {}
1122
+
1123
+ ngOnInit() {
1124
+ }
1125
+
1126
+ }
1127
+
1128
+ `
1129
+ );
1130
+
1131
+ addConstructorContent(appTree, filePath, 'router.initialNavigation();', true);
1132
+
1133
+ const content = appTree.read(filePath)?.toString();
1134
+ expect(content).toContain('constructor() {\n router.initialNavigation();\n }');
1135
+
1136
+ done();
1137
+ });
1138
+
1139
+ it('Sollte Inhalt im Konstruktor (ohne Konstruktor - append=false) hinzufügen', (done) => {
1140
+ const filePath = testOptions.path + '/src/app/test.component.ts';
1141
+
1142
+ appTree.create(
1143
+ filePath,
1144
+ `
1145
+ @Component({
1146
+ selector : 'bp-anbindung-lazy',
1147
+ templateUrl: './anbindung-lazy.component.html'
1148
+ })
1149
+ export class AnbindungLazyComponent extends Aaa {
1150
+
1151
+ ngOnInit() {
1152
+ }
1153
+
1154
+ }
1155
+
1156
+ `
1157
+ );
1158
+
1159
+ addConstructorContent(appTree, filePath, 'router.initialNavigation();', false);
1160
+
1161
+ const content = appTree.read(filePath)?.toString();
1162
+
1163
+ expect(content).toContain('constructor() {\n router.initialNavigation();\n }');
1164
+
1165
+ done();
1166
+ });
1167
+
1168
+ it('Sollte Inhalt im Konstruktor (ohne Konstruktor - append=true) hinzufügen', (done) => {
1169
+ const filePath = testOptions.path + '/src/app/test.component.ts';
1170
+
1171
+ appTree.create(
1172
+ filePath,
1173
+ `
1174
+ @Component({
1175
+ selector : 'bp-anbindung-lazy',
1176
+ templateUrl: './anbindung-lazy.component.html'
1177
+ })
1178
+ export class AnbindungLazyComponent extends Aaa {
1179
+
1180
+ ngOnInit() {
1181
+ }
1182
+
1183
+ }
1184
+
1185
+ `
1186
+ );
1187
+
1188
+ addConstructorContent(appTree, filePath, 'router.initialNavigation();', true);
1189
+
1190
+ const content = appTree.read(filePath)?.toString();
1191
+ expect(content).toContain('constructor() {\n router.initialNavigation();\n }');
1192
+
1193
+ done();
1194
+ });
1195
+ });
1196
+
1197
+ describe('[Method] addClassProperty', () => {
1198
+ it('Sollte eine Property (mit Properties) hinzufügen', (done) => {
1199
+ const filePath = testOptions.path + '/src/app/test.component.ts';
1200
+
1201
+ appTree.create(
1202
+ filePath,
1203
+ `
1204
+ @Component({
1205
+ selector : 'app-root',
1206
+ templateUrl: './app.component.html',
1207
+ styleUrls : [ './app.component.scss' ]
1208
+ })
1209
+ export class AppComponent implements OnInit {
1210
+
1211
+ luxVersion = '';
1212
+ isMaintenanceOrUnauthorized = false;
1213
+
1214
+ constructor(private readonly fachService: AccountFacadeService,
1215
+ public router: Router, public window: Window,
1216
+ private appService: LuxAppService) {
1217
+ }
1218
+
1219
+ ngOnInit(): void {
1220
+ }
1221
+
1222
+ }
1223
+ `
1224
+ );
1225
+
1226
+ addClassProperty(appTree, filePath, '@Input() luxAppHeader: \'normal\' | \'minimal\' | \'none\' = \'normal\';');
1227
+
1228
+ const content = appTree.read(filePath)?.toString();
1229
+ expect(content).toContain(' @Input() luxAppHeader: \'normal\' | \'minimal\' | \'none\' = \'normal\';');
1230
+
1231
+ done();
1232
+ });
1233
+
1234
+ it('Sollte eine Property (ohne Properties) hinzufügen', (done) => {
1235
+ const filePath = testOptions.path + '/src/app/test.component.ts';
1236
+
1237
+ appTree.create(
1238
+ filePath,
1239
+ `
1240
+ @Component({
1241
+ selector : 'app-root',
1242
+ templateUrl: './app.component.html',
1243
+ styleUrls : [ './app.component.scss' ]
1244
+ })
1245
+ export class AppComponent implements OnInit {
1246
+
1247
+ constructor(private readonly fachService: AccountFacadeService,
1248
+ public router: Router, public window: Window,
1249
+ private appService: LuxAppService) {
1250
+ }
1251
+
1252
+ ngOnInit(): void {
1253
+ }
1254
+
1255
+ }
1256
+ `
1257
+ );
1258
+
1259
+ addClassProperty(appTree, filePath, '@Input() luxAppHeader: \'normal\' | \'minimal\' | \'none\' = \'normal\';');
1260
+
1261
+ const content = appTree.read(filePath)?.toString();
1262
+ expect(content).toContain(' @Input() luxAppHeader: \'normal\' | \'minimal\' | \'none\' = \'normal\';');
1263
+
1264
+ done();
1265
+ });
1266
+ });
1267
+ });