@taiga-ui/cdk 3.45.0-canary.019e39b → 3.45.0-canary.5c5ad77

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 (62) hide show
  1. package/bundles/taiga-ui-cdk-directives-active-zone.umd.js +8 -15
  2. package/bundles/taiga-ui-cdk-directives-active-zone.umd.js.map +1 -1
  3. package/esm2015/directives/active-zone/active-zone.directive.js +9 -16
  4. package/fesm2015/taiga-ui-cdk-directives-active-zone.js +8 -15
  5. package/fesm2015/taiga-ui-cdk-directives-active-zone.js.map +1 -1
  6. package/package.json +4 -4
  7. package/schematics/ng-add/tests/schematic-ng-add-standalone.spec.d.ts +0 -1
  8. package/schematics/ng-add/tests/schematic-ng-add-standalone.spec.js +0 -381
  9. package/schematics/ng-add/tests/schematic-ng-add.spec.d.ts +0 -1
  10. package/schematics/ng-add/tests/schematic-ng-add.spec.js +0 -270
  11. package/schematics/ng-update/v3/tests/schematic-date-time.spec.d.ts +0 -1
  12. package/schematics/ng-update/v3/tests/schematic-date-time.spec.js +0 -117
  13. package/schematics/ng-update/v3/tests/schematic-migrate-hints.spec.d.ts +0 -1
  14. package/schematics/ng-update/v3/tests/schematic-migrate-hints.spec.js +0 -102
  15. package/schematics/ng-update/v3/tests/schematic-migrate-polymorpheus.spec.d.ts +0 -1
  16. package/schematics/ng-update/v3/tests/schematic-migrate-polymorpheus.spec.js +0 -107
  17. package/schematics/ng-update/v3/tests/schematic-migrate-progress.spec.d.ts +0 -1
  18. package/schematics/ng-update/v3/tests/schematic-migrate-progress.spec.js +0 -113
  19. package/schematics/ng-update/v3/tests/schematic-migrate-sliders.spec.d.ts +0 -1
  20. package/schematics/ng-update/v3/tests/schematic-migrate-sliders.spec.js +0 -380
  21. package/schematics/ng-update/v3/tests/schematic-migrate-tds.spec.d.ts +0 -1
  22. package/schematics/ng-update/v3/tests/schematic-migrate-tds.spec.js +0 -119
  23. package/schematics/ng-update/v3/tests/schematic-migrate-textfields.spec.d.ts +0 -1
  24. package/schematics/ng-update/v3/tests/schematic-migrate-textfields.spec.js +0 -123
  25. package/schematics/ng-update/v3/tests/schematic-miscellaneous.spec.d.ts +0 -1
  26. package/schematics/ng-update/v3/tests/schematic-miscellaneous.spec.js +0 -81
  27. package/schematics/ng-update/v3/tests/schematic-rename-types.spec.d.ts +0 -1
  28. package/schematics/ng-update/v3/tests/schematic-rename-types.spec.js +0 -157
  29. package/schematics/ng-update/v3/tests/schematic-replace-consts.spec.d.ts +0 -1
  30. package/schematics/ng-update/v3/tests/schematic-replace-consts.spec.js +0 -135
  31. package/schematics/ng-update/v3/tests/schematic-replace-deep-imports.spec.d.ts +0 -1
  32. package/schematics/ng-update/v3/tests/schematic-replace-deep-imports.spec.js +0 -53
  33. package/schematics/ng-update/v3/tests/schematic-replace-deprecated-functions.spec.d.ts +0 -1
  34. package/schematics/ng-update/v3/tests/schematic-replace-deprecated-functions.spec.js +0 -835
  35. package/schematics/ng-update/v3/tests/schematic-replace-enums.spec.d.ts +0 -1
  36. package/schematics/ng-update/v3/tests/schematic-replace-enums.spec.js +0 -68
  37. package/schematics/ng-update/v3/tests/schematic-replace-functions.spec.d.ts +0 -1
  38. package/schematics/ng-update/v3/tests/schematic-replace-functions.spec.js +0 -195
  39. package/schematics/ng-update/v3/tests/schematic-replace-html.spec.d.ts +0 -1
  40. package/schematics/ng-update/v3/tests/schematic-replace-html.spec.js +0 -611
  41. package/schematics/ng-update/v3/tests/schematic-replace-proprietary-consts.spec.d.ts +0 -1
  42. package/schematics/ng-update/v3/tests/schematic-replace-proprietary-consts.spec.js +0 -100
  43. package/schematics/ng-update/v3/tests/schematic-replace-services.spec.d.ts +0 -1
  44. package/schematics/ng-update/v3/tests/schematic-replace-services.spec.js +0 -102
  45. package/schematics/ng-update/v3/tests/schematic-replace-styles.spec.d.ts +0 -1
  46. package/schematics/ng-update/v3/tests/schematic-replace-styles.spec.js +0 -286
  47. package/schematics/ng-update/v3/tests/schematic-textfield-icon.spec.d.ts +0 -1
  48. package/schematics/ng-update/v3/tests/schematic-textfield-icon.spec.js +0 -141
  49. package/schematics/ng-update/v3/tests/schematic-warnings.spec.d.ts +0 -1
  50. package/schematics/ng-update/v3/tests/schematic-warnings.spec.js +0 -104
  51. package/schematics/ng-update/v3-30/tests/schematic-migrate-icons.spec.d.ts +0 -1
  52. package/schematics/ng-update/v3-30/tests/schematic-migrate-icons.spec.js +0 -87
  53. package/schematics/ng-update/v3-35/tests/schematic-migrate-icons.spec.d.ts +0 -1
  54. package/schematics/ng-update/v3-35/tests/schematic-migrate-icons.spec.js +0 -101
  55. package/schematics/ng-update/v3-36/tests/schematic-migrate-editor.spec.d.ts +0 -1
  56. package/schematics/ng-update/v3-36/tests/schematic-migrate-editor.spec.js +0 -117
  57. package/schematics/ng-update/v3-40/tests/schematic-migrate-textarea.spec.d.ts +0 -1
  58. package/schematics/ng-update/v3-40/tests/schematic-migrate-textarea.spec.js +0 -90
  59. package/schematics/ng-update/v3-5/tests/schematic-migrate-templates.spec.d.ts +0 -1
  60. package/schematics/ng-update/v3-5/tests/schematic-migrate-templates.spec.js +0 -74
  61. package/schematics/ng-update/v4/tests/schematic-migrate-thumbnail-card.spec.d.ts +0 -1
  62. package/schematics/ng-update/v4/tests/schematic-migrate-thumbnail-card.spec.js +0 -72
@@ -1,381 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- /* eslint-disable rxjs/no-topromise */
5
- const schematics_1 = require("@angular-devkit/schematics");
6
- const testing_1 = require("@angular-devkit/schematics/testing");
7
- const ng_morph_1 = require("ng-morph");
8
- const path_1 = require("path");
9
- const create_angular_json_1 = require("../../utils/create-angular-json");
10
- const versions_1 = require("../constants/versions");
11
- const collectionPath = path_1.join(__dirname, `../../collection.json`);
12
- describe(`ng-add [Standalone]`, () => {
13
- let host;
14
- let runner;
15
- beforeEach(() => {
16
- host = new testing_1.UnitTestTree(new schematics_1.HostTree());
17
- runner = new testing_1.SchematicTestRunner(`schematics`, collectionPath);
18
- ng_morph_1.setActiveProject(ng_morph_1.createProject(host));
19
- ng_morph_1.createSourceFile(`package.json`, `{"dependencies": {"@angular/core": "~13.0.0"}}`);
20
- create_angular_json_1.createAngularJson();
21
- createMainStandaloneFiles();
22
- ng_morph_1.saveActiveProject();
23
- });
24
- it(`should add main modules in package.json`, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
25
- const options = {
26
- addSanitizer: false,
27
- addGlobalStyles: false,
28
- addDialogsModule: false,
29
- addAlertModule: false,
30
- addons: [],
31
- project: ``,
32
- 'skip-logs': process.env[`TUI_CI`] === `true`,
33
- };
34
- const tree = yield runner.runSchematicAsync(`ng-add`, options, host).toPromise();
35
- expect(tree.readContent(`package.json`)).toEqual(`{
36
- "dependencies": {
37
- "@angular/core": "~13.0.0",
38
- "@taiga-ui/cdk": "${versions_1.TAIGA_VERSION}",
39
- "@taiga-ui/core": "${versions_1.TAIGA_VERSION}",
40
- "@taiga-ui/icons": "${versions_1.TAIGA_VERSION}",
41
- "@taiga-ui/kit": "${versions_1.TAIGA_VERSION}"
42
- }
43
- }`);
44
- }));
45
- it(`should add additional modules in package.json`, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
46
- const options = {
47
- addSanitizer: true,
48
- addGlobalStyles: false,
49
- addDialogsModule: false,
50
- addAlertModule: false,
51
- addons: [`addon-doc`, `addon-mobile`],
52
- project: ``,
53
- 'skip-logs': process.env[`TUI_CI`] === `true`,
54
- };
55
- const tree = yield runner.runSchematicAsync(`ng-add`, options, host).toPromise();
56
- expect(tree.readContent(`package.json`)).toEqual(`{
57
- "devDependencies": {
58
- "@types/dompurify": "${versions_1.DOMPURIFY_TYPES_VERSION}"
59
- },
60
- "dependencies": {
61
- "@angular/cdk": "^13.0.0",
62
- "@angular/core": "~13.0.0",
63
- "@taiga-ui/addon-doc": "${versions_1.TAIGA_VERSION}",
64
- "@taiga-ui/addon-mobile": "${versions_1.TAIGA_VERSION}",
65
- "@taiga-ui/cdk": "${versions_1.TAIGA_VERSION}",
66
- "@taiga-ui/core": "${versions_1.TAIGA_VERSION}",
67
- "@taiga-ui/icons": "${versions_1.TAIGA_VERSION}",
68
- "@taiga-ui/kit": "${versions_1.TAIGA_VERSION}",
69
- "@tinkoff/ng-dompurify": "${versions_1.NG_DOMPURIFY_VERSION}",
70
- "dompurify": "${versions_1.DOMPURIFY_VERSION}"
71
- }
72
- }`);
73
- }));
74
- it(`should add additional modules in package.json and global styles`, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
75
- const options = {
76
- addSanitizer: true,
77
- addGlobalStyles: true,
78
- addDialogsModule: false,
79
- addAlertModule: false,
80
- addons: [`addon-doc`, `addon-mobile`],
81
- project: ``,
82
- 'skip-logs': process.env[`TUI_CI`] === `true`,
83
- };
84
- const tree = yield runner.runSchematicAsync(`ng-add`, options, host).toPromise();
85
- expect(tree.readContent(`package.json`)).toEqual(`{
86
- "devDependencies": {
87
- "@types/dompurify": "${versions_1.DOMPURIFY_TYPES_VERSION}"
88
- },
89
- "dependencies": {
90
- "@angular/cdk": "^13.0.0",
91
- "@angular/core": "~13.0.0",
92
- "@taiga-ui/addon-doc": "${versions_1.TAIGA_VERSION}",
93
- "@taiga-ui/addon-mobile": "${versions_1.TAIGA_VERSION}",
94
- "@taiga-ui/cdk": "${versions_1.TAIGA_VERSION}",
95
- "@taiga-ui/core": "${versions_1.TAIGA_VERSION}",
96
- "@taiga-ui/icons": "${versions_1.TAIGA_VERSION}",
97
- "@taiga-ui/kit": "${versions_1.TAIGA_VERSION}",
98
- "@taiga-ui/styles": "${versions_1.TAIGA_VERSION}",
99
- "@tinkoff/ng-dompurify": "${versions_1.NG_DOMPURIFY_VERSION}",
100
- "dompurify": "${versions_1.DOMPURIFY_VERSION}"
101
- }
102
- }`);
103
- }));
104
- it(`should add assets and styles in angular.json`, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
105
- const tree = yield runner
106
- .runSchematicAsync(`ng-add-setup-project`, { 'skip-logs': process.env[`TUI_CI`] === `true` }, host)
107
- .toPromise();
108
- expect(tree.readContent(`angular.json`)).toEqual(`
109
- {
110
- "version": 1,
111
- "defaultProject": "demo",
112
- "projects": {
113
- "demo": {
114
- "architect": {
115
- "build": {
116
- "options": {
117
- "main": "test/main.ts",
118
- "styles": [
119
- "node_modules/@taiga-ui/core/styles/taiga-ui-theme.less",
120
- "node_modules/@taiga-ui/core/styles/taiga-ui-fonts.less"
121
- ],
122
- "assets": [
123
- {
124
- "glob": "**/*",
125
- "input": "node_modules/@taiga-ui/icons/src",
126
- "output": "assets/taiga-ui/icons"
127
- }
128
- ]
129
- }
130
- }
131
- }
132
- }
133
- }
134
- }`);
135
- }));
136
- it(`should add styles without duplicates, taiga styles first`, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
137
- create_angular_json_1.createAngularJson({ stylesExist: true });
138
- ng_morph_1.saveActiveProject();
139
- const tree = yield runner
140
- .runSchematicAsync(`ng-add-setup-project`, { 'skip-logs': process.env[`TUI_CI`] === `true` }, host)
141
- .toPromise();
142
- expect(tree.readContent(`angular.json`)).toEqual(`
143
- {
144
- "version": 1,
145
- "defaultProject": "demo",
146
- "projects": {
147
- "demo": {
148
- "architect": {
149
- "build": {
150
- "options": {
151
- "main": "test/main.ts",
152
- "styles": [
153
- "node_modules/@taiga-ui/core/styles/taiga-ui-theme.less",
154
- "node_modules/@taiga-ui/core/styles/taiga-ui-fonts.less",
155
- "some.style"
156
- ],
157
- "assets": [
158
- {
159
- "glob": "**/*",
160
- "input": "node_modules/@taiga-ui/icons/src",
161
- "output": "assets/taiga-ui/icons"
162
- }
163
- ]
164
- }
165
- }
166
- }
167
- }
168
- }
169
- }`);
170
- }));
171
- it(`should add global styles`, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
172
- create_angular_json_1.createAngularJson({ stylesExist: true });
173
- ng_morph_1.saveActiveProject();
174
- const tree = yield runner
175
- .runSchematicAsync(`ng-add-setup-project`, { addGlobalStyles: true }, host)
176
- .toPromise();
177
- expect(tree.readContent(`angular.json`)).toEqual(`
178
- {
179
- "version": 1,
180
- "defaultProject": "demo",
181
- "projects": {
182
- "demo": {
183
- "architect": {
184
- "build": {
185
- "options": {
186
- "main": "test/main.ts",
187
- "styles": [
188
- "node_modules/@taiga-ui/core/styles/taiga-ui-theme.less",
189
- "node_modules/@taiga-ui/core/styles/taiga-ui-fonts.less",
190
- "node_modules/@taiga-ui/styles/taiga-ui-global.less",
191
- "some.style"
192
- ],
193
- "assets": [
194
- {
195
- "glob": "**/*",
196
- "input": "node_modules/@taiga-ui/icons/src",
197
- "output": "assets/taiga-ui/icons"
198
- }
199
- ]
200
- }
201
- }
202
- }
203
- }
204
- }
205
- }`);
206
- }));
207
- it(`Should add Taiga-ui modules and providers to main component`, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
208
- const options = {
209
- addSanitizer: true,
210
- addGlobalStyles: false,
211
- addDialogsModule: true,
212
- addAlertModule: true,
213
- addons: [],
214
- project: ``,
215
- 'skip-logs': process.env[`TUI_CI`] === `true`,
216
- };
217
- const tree = yield runner
218
- .runSchematicAsync(`ng-add-setup-project`, options, host)
219
- .toPromise();
220
- expect(tree.readContent(`test/app/app.component.ts`)).toEqual(`import { NgDompurifySanitizer } from "@tinkoff/ng-dompurify";
221
- import { TuiRootModule, TuiDialogModule, TuiAlertModule, TUI_SANITIZER } from "@taiga-ui/core";
222
- import { Component } from '@angular/core';
223
- import { RouterModule } from '@angular/router';
224
-
225
- @Component({
226
- standalone: true,
227
- imports: [RouterModule, TuiRootModule, TuiDialogModule, TuiAlertModule],
228
- selector: 'standalone-test-root',
229
- templateUrl: './app.template.html',
230
- styleUrls: ['./app.component.less'],
231
- providers: [{provide: TUI_SANITIZER, useClass: NgDompurifySanitizer}]
232
- })
233
- export class AppComponent {
234
- title = 'standalone-test';
235
- }`);
236
- }));
237
- it(`Should wrap main template with tui-root`, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
238
- const tree = yield runner
239
- .runSchematicAsync(`ng-add-setup-project`, { 'skip-logs': process.env[`TUI_CI`] === `true` }, host)
240
- .toPromise();
241
- expect(tree.readContent(`test/app/app.template.html`)).toEqual(`<tui-root>
242
- <app></app>
243
- </tui-root>`);
244
- }));
245
- it(`[Standalone] Should add main providers to bootstrap fn`, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
246
- const tree = yield runner
247
- .runSchematicAsync(`ng-add-setup-project`, { 'skip-logs': process.env[`TUI_CI`] === `true` }, host)
248
- .toPromise();
249
- expect(tree.readContent(`test/main.ts`))
250
- .toEqual(`import { importProvidersFrom } from "@angular/core";
251
- import { TuiRootModule } from "@taiga-ui/core";
252
- import { bootstrapApplication } from '@angular/platform-browser';
253
- import {
254
- provideRouter,
255
- withEnabledBlockingInitialNavigation,
256
- } from '@angular/router';
257
- import { provideAnimations } from '@angular/platform-browser/animations';
258
- import { appRoutes } from './app/app.routes';
259
- import { AppComponent } from './app/app.component';
260
-
261
- bootstrapApplication(AppComponent, {
262
- providers: [provideAnimations(), provideRouter(appRoutes, withEnabledBlockingInitialNavigation()), importProvidersFrom(SomeModule, TuiRootModule)],
263
- }).catch((err) => console.error(err));
264
- `);
265
- }));
266
- it(`[Standalone] Should add main providers to bootstrap fn (appConfig)`, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
267
- createMainWithConfig();
268
- ng_morph_1.saveActiveProject();
269
- const tree = yield runner
270
- .runSchematicAsync(`ng-add-setup-project`, { 'skip-logs': process.env[`TUI_CI`] === `true` }, host)
271
- .toPromise();
272
- expect(tree.readContent(`test/app/app.config.ts`))
273
- .toEqual(`import { TuiRootModule } from "@taiga-ui/core";
274
-
275
- import { ApplicationConfig, importProvidersFrom } from '@angular/core';
276
- import {
277
- provideRouter,
278
- withEnabledBlockingInitialNavigation,
279
- } from '@angular/router';
280
- import { provideAnimations } from '@angular/platform-browser/animations';
281
- import { appRoutes } from './app.routes';
282
-
283
- export const appConfig: ApplicationConfig = {
284
- providers: [provideRouter(appRoutes, withEnabledBlockingInitialNavigation()), provideAnimations(), importProvidersFrom(TuiRootModule)],
285
- };`);
286
- }));
287
- it(`[Standalone] Should add Taiga-ui modules and provideAnimation`, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
288
- createMainWithoutAnimation();
289
- ng_morph_1.saveActiveProject();
290
- const tree = yield runner
291
- .runSchematicAsync(`ng-add-setup-project`, { 'skip-logs': process.env[`TUI_CI`] === `true` }, host)
292
- .toPromise();
293
- expect(tree.readContent(`test/main.ts`))
294
- .toEqual(`import { importProvidersFrom } from "@angular/core";
295
- import { providerAnimation } from "@angular/platform-browser/animations";
296
- import { TuiRootModule } from "@taiga-ui/core";
297
- import { bootstrapApplication } from '@angular/platform-browser';
298
- import {
299
- provideRouter,
300
- withEnabledBlockingInitialNavigation,
301
- } from '@angular/router';
302
- import { appRoutes } from './app/app.routes';
303
- import { AppComponent } from './app/app.component';
304
-
305
- bootstrapApplication(AppComponent, {
306
- providers: [providerAnimation(), provideRouter(appRoutes, withEnabledBlockingInitialNavigation()), importProvidersFrom(TuiRootModule)],
307
- }).catch((err) => console.error(err));
308
- `);
309
- }));
310
- afterEach(() => {
311
- ng_morph_1.resetActiveProject();
312
- });
313
- });
314
- function createMainStandaloneFiles() {
315
- ng_morph_1.createSourceFile(`test/main.ts`, `import { bootstrapApplication } from '@angular/platform-browser';
316
- import {
317
- provideRouter,
318
- withEnabledBlockingInitialNavigation,
319
- } from '@angular/router';
320
- import { provideAnimations } from '@angular/platform-browser/animations';
321
- import { appRoutes } from './app/app.routes';
322
- import { AppComponent } from './app/app.component';
323
-
324
- bootstrapApplication(AppComponent, {
325
- providers: [provideAnimations(), provideRouter(appRoutes, withEnabledBlockingInitialNavigation()), importProvidersFrom(SomeModule)],
326
- }).catch((err) => console.error(err));
327
- `, { overwrite: true });
328
- ng_morph_1.createSourceFile(`test/app/app.component.ts`, `import { Component } from '@angular/core';
329
- import { RouterModule } from '@angular/router';
330
-
331
- @Component({
332
- standalone: true,
333
- imports: [RouterModule],
334
- selector: 'standalone-test-root',
335
- templateUrl: './app.template.html',
336
- styleUrls: ['./app.component.less'],
337
- })
338
- export class AppComponent {
339
- title = 'standalone-test';
340
- }`, { overwrite: true });
341
- ng_morph_1.createSourceFile(`test/app/app.template.html`, `<app></app>`, { overwrite: true });
342
- }
343
- function createMainWithoutAnimation() {
344
- ng_morph_1.createSourceFile(`test/main.ts`, `import { bootstrapApplication } from '@angular/platform-browser';
345
- import {
346
- provideRouter,
347
- withEnabledBlockingInitialNavigation,
348
- } from '@angular/router';
349
- import { appRoutes } from './app/app.routes';
350
- import { AppComponent } from './app/app.component';
351
-
352
- bootstrapApplication(AppComponent, {
353
- providers: [provideRouter(appRoutes, withEnabledBlockingInitialNavigation())],
354
- }).catch((err) => console.error(err));
355
- `, { overwrite: true });
356
- }
357
- function createMainWithConfig() {
358
- ng_morph_1.createSourceFile(`test/main.ts`, `import { bootstrapApplication } from '@angular/platform-browser';
359
- import {
360
- provideRouter,
361
- withEnabledBlockingInitialNavigation,
362
- } from '@angular/router';
363
- import { appRoutes } from './app/app.routes';
364
- import { AppComponent } from './app/app.component';
365
- import { appConfig } from './app/app.config';
366
-
367
- bootstrapApplication(AppComponent, appConfig).catch((err) => console.error(err));
368
- `, { overwrite: true });
369
- ng_morph_1.createSourceFile(`test/app/app.config.ts`, `
370
- import { ApplicationConfig } from '@angular/core';
371
- import {
372
- provideRouter,
373
- withEnabledBlockingInitialNavigation,
374
- } from '@angular/router';
375
- import { provideAnimations } from '@angular/platform-browser/animations';
376
- import { appRoutes } from './app.routes';
377
-
378
- export const appConfig: ApplicationConfig = {
379
- providers: [provideRouter(appRoutes, withEnabledBlockingInitialNavigation()), provideAnimations()],
380
- };`, { overwrite: true });
381
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,270 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- /* eslint-disable rxjs/no-topromise */
5
- const schematics_1 = require("@angular-devkit/schematics");
6
- const testing_1 = require("@angular-devkit/schematics/testing");
7
- const ng_morph_1 = require("ng-morph");
8
- const path_1 = require("path");
9
- const create_angular_json_1 = require("../../utils/create-angular-json");
10
- const versions_1 = require("../constants/versions");
11
- const collectionPath = path_1.join(__dirname, `../../collection.json`);
12
- describe(`ng-add`, () => {
13
- let host;
14
- let runner;
15
- beforeEach(() => {
16
- host = new testing_1.UnitTestTree(new schematics_1.HostTree());
17
- runner = new testing_1.SchematicTestRunner(`schematics`, collectionPath);
18
- ng_morph_1.setActiveProject(ng_morph_1.createProject(host));
19
- ng_morph_1.createSourceFile(`package.json`, `{"dependencies": {"@angular/core": "~13.0.0"}}`);
20
- create_angular_json_1.createAngularJson();
21
- createMainFiles();
22
- ng_morph_1.saveActiveProject();
23
- });
24
- it(`should add main modules in package.json`, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
25
- const options = {
26
- addSanitizer: false,
27
- addGlobalStyles: false,
28
- addDialogsModule: false,
29
- addAlertModule: false,
30
- addons: [],
31
- project: ``,
32
- 'skip-logs': process.env[`TUI_CI`] === `true`,
33
- };
34
- const tree = yield runner.runSchematicAsync(`ng-add`, options, host).toPromise();
35
- expect(tree.readContent(`package.json`)).toEqual(`{
36
- "dependencies": {
37
- "@angular/core": "~13.0.0",
38
- "@taiga-ui/cdk": "${versions_1.TAIGA_VERSION}",
39
- "@taiga-ui/core": "${versions_1.TAIGA_VERSION}",
40
- "@taiga-ui/icons": "${versions_1.TAIGA_VERSION}",
41
- "@taiga-ui/kit": "${versions_1.TAIGA_VERSION}"
42
- }
43
- }`);
44
- }));
45
- it(`should add additional modules in package.json`, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
46
- const options = {
47
- addSanitizer: true,
48
- addGlobalStyles: false,
49
- addDialogsModule: false,
50
- addAlertModule: false,
51
- addons: [`addon-doc`, `addon-mobile`],
52
- project: ``,
53
- 'skip-logs': process.env[`TUI_CI`] === `true`,
54
- };
55
- const tree = yield runner.runSchematicAsync(`ng-add`, options, host).toPromise();
56
- expect(tree.readContent(`package.json`)).toEqual(`{
57
- "devDependencies": {
58
- "@types/dompurify": "${versions_1.DOMPURIFY_TYPES_VERSION}"
59
- },
60
- "dependencies": {
61
- "@angular/cdk": "^13.0.0",
62
- "@angular/core": "~13.0.0",
63
- "@taiga-ui/addon-doc": "${versions_1.TAIGA_VERSION}",
64
- "@taiga-ui/addon-mobile": "${versions_1.TAIGA_VERSION}",
65
- "@taiga-ui/cdk": "${versions_1.TAIGA_VERSION}",
66
- "@taiga-ui/core": "${versions_1.TAIGA_VERSION}",
67
- "@taiga-ui/icons": "${versions_1.TAIGA_VERSION}",
68
- "@taiga-ui/kit": "${versions_1.TAIGA_VERSION}",
69
- "@tinkoff/ng-dompurify": "${versions_1.NG_DOMPURIFY_VERSION}",
70
- "dompurify": "${versions_1.DOMPURIFY_VERSION}"
71
- }
72
- }`);
73
- }));
74
- it(`should add additional modules in package.json and global styles`, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
75
- const options = {
76
- addSanitizer: true,
77
- addGlobalStyles: true,
78
- addDialogsModule: false,
79
- addAlertModule: false,
80
- addons: [`addon-doc`, `addon-mobile`],
81
- project: ``,
82
- 'skip-logs': process.env[`TUI_CI`] === `true`,
83
- };
84
- const tree = yield runner.runSchematicAsync(`ng-add`, options, host).toPromise();
85
- expect(tree.readContent(`package.json`)).toEqual(`{
86
- "devDependencies": {
87
- "@types/dompurify": "${versions_1.DOMPURIFY_TYPES_VERSION}"
88
- },
89
- "dependencies": {
90
- "@angular/cdk": "^13.0.0",
91
- "@angular/core": "~13.0.0",
92
- "@taiga-ui/addon-doc": "${versions_1.TAIGA_VERSION}",
93
- "@taiga-ui/addon-mobile": "${versions_1.TAIGA_VERSION}",
94
- "@taiga-ui/cdk": "${versions_1.TAIGA_VERSION}",
95
- "@taiga-ui/core": "${versions_1.TAIGA_VERSION}",
96
- "@taiga-ui/icons": "${versions_1.TAIGA_VERSION}",
97
- "@taiga-ui/kit": "${versions_1.TAIGA_VERSION}",
98
- "@taiga-ui/styles": "${versions_1.TAIGA_VERSION}",
99
- "@tinkoff/ng-dompurify": "${versions_1.NG_DOMPURIFY_VERSION}",
100
- "dompurify": "${versions_1.DOMPURIFY_VERSION}"
101
- }
102
- }`);
103
- }));
104
- it(`should add assets and styles in angular.json`, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
105
- const tree = yield runner
106
- .runSchematicAsync(`ng-add-setup-project`, { 'skip-logs': process.env[`TUI_CI`] === `true` }, host)
107
- .toPromise();
108
- expect(tree.readContent(`angular.json`)).toEqual(`
109
- {
110
- "version": 1,
111
- "defaultProject": "demo",
112
- "projects": {
113
- "demo": {
114
- "architect": {
115
- "build": {
116
- "options": {
117
- "main": "test/main.ts",
118
- "styles": [
119
- "node_modules/@taiga-ui/core/styles/taiga-ui-theme.less",
120
- "node_modules/@taiga-ui/core/styles/taiga-ui-fonts.less"
121
- ],
122
- "assets": [
123
- {
124
- "glob": "**/*",
125
- "input": "node_modules/@taiga-ui/icons/src",
126
- "output": "assets/taiga-ui/icons"
127
- }
128
- ]
129
- }
130
- }
131
- }
132
- }
133
- }
134
- }`);
135
- }));
136
- it(`should add styles without duplicates, taiga styles first`, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
137
- create_angular_json_1.createAngularJson({ stylesExist: true });
138
- ng_morph_1.saveActiveProject();
139
- const tree = yield runner
140
- .runSchematicAsync(`ng-add-setup-project`, { 'skip-logs': process.env[`TUI_CI`] === `true` }, host)
141
- .toPromise();
142
- expect(tree.readContent(`angular.json`)).toEqual(`
143
- {
144
- "version": 1,
145
- "defaultProject": "demo",
146
- "projects": {
147
- "demo": {
148
- "architect": {
149
- "build": {
150
- "options": {
151
- "main": "test/main.ts",
152
- "styles": [
153
- "node_modules/@taiga-ui/core/styles/taiga-ui-theme.less",
154
- "node_modules/@taiga-ui/core/styles/taiga-ui-fonts.less",
155
- "some.style"
156
- ],
157
- "assets": [
158
- {
159
- "glob": "**/*",
160
- "input": "node_modules/@taiga-ui/icons/src",
161
- "output": "assets/taiga-ui/icons"
162
- }
163
- ]
164
- }
165
- }
166
- }
167
- }
168
- }
169
- }`);
170
- }));
171
- it(`should add global styles`, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
172
- create_angular_json_1.createAngularJson({ stylesExist: true });
173
- ng_morph_1.saveActiveProject();
174
- const tree = yield runner
175
- .runSchematicAsync(`ng-add-setup-project`, { addGlobalStyles: true }, host)
176
- .toPromise();
177
- expect(tree.readContent(`angular.json`)).toEqual(`
178
- {
179
- "version": 1,
180
- "defaultProject": "demo",
181
- "projects": {
182
- "demo": {
183
- "architect": {
184
- "build": {
185
- "options": {
186
- "main": "test/main.ts",
187
- "styles": [
188
- "node_modules/@taiga-ui/core/styles/taiga-ui-theme.less",
189
- "node_modules/@taiga-ui/core/styles/taiga-ui-fonts.less",
190
- "node_modules/@taiga-ui/styles/taiga-ui-global.less",
191
- "some.style"
192
- ],
193
- "assets": [
194
- {
195
- "glob": "**/*",
196
- "input": "node_modules/@taiga-ui/icons/src",
197
- "output": "assets/taiga-ui/icons"
198
- }
199
- ]
200
- }
201
- }
202
- }
203
- }
204
- }
205
- }`);
206
- }));
207
- it(`Should add Taiga-ui modules and providers to main module`, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
208
- const options = {
209
- addSanitizer: true,
210
- addGlobalStyles: false,
211
- addDialogsModule: true,
212
- addAlertModule: true,
213
- addons: [],
214
- project: ``,
215
- 'skip-logs': process.env[`TUI_CI`] === `true`,
216
- };
217
- const tree = yield runner
218
- .runSchematicAsync(`ng-add-setup-project`, options, host)
219
- .toPromise();
220
- expect(tree.readContent(`test/app/app.module.ts`)).toEqual(`import { NgDompurifySanitizer } from "@tinkoff/ng-dompurify";
221
- import { TuiRootModule, TuiDialogModule, TuiAlertModule, TUI_SANITIZER } from "@taiga-ui/core";
222
- import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
223
- import {NgModule} from '@angular/core';
224
- import {AppComponent} from './app.component';
225
-
226
- @NgModule({declarations: [AppComponent],
227
- imports: [BrowserAnimationsModule, TuiRootModule, TuiDialogModule, TuiAlertModule],
228
- providers: [{provide: TUI_SANITIZER, useClass: NgDompurifySanitizer}]
229
- })
230
- export class AppModule {}
231
- `);
232
- }));
233
- it(`Should wrap main template with tui-root`, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
234
- const tree = yield runner
235
- .runSchematicAsync(`ng-add-setup-project`, { 'skip-logs': process.env[`TUI_CI`] === `true` }, host)
236
- .toPromise();
237
- expect(tree.readContent(`test/app/app.template.html`)).toEqual(`<tui-root>
238
- <app></app>
239
- </tui-root>`);
240
- }));
241
- afterEach(() => {
242
- ng_morph_1.resetActiveProject();
243
- });
244
- });
245
- function createMainFiles() {
246
- ng_morph_1.createSourceFile(`test/main.ts`, `import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
247
- import {AppModule} from './app/app.module';
248
- import {environment} from './environments/environment';
249
-
250
- if (environment.production) {
251
- enableProdMode();
252
- }
253
-
254
- platformBrowserDynamic()
255
- .bootstrapModule(AppModule)
256
- .catch(err => console.log(err));
257
- `);
258
- ng_morph_1.createSourceFile(`test/app/app.module.ts`, `import {NgModule} from '@angular/core';
259
- import {AppComponent} from './app.component';
260
-
261
- @NgModule({declarations: [AppComponent]})
262
- export class AppModule {}
263
- `);
264
- ng_morph_1.createSourceFile(`test/app/app.component.ts`, `import {Component} from '@angular/core';
265
- import {AppComponent} from './app.component';
266
-
267
- @Component({templateUrl: './app.template.html'})
268
- export class AppComponent {}`);
269
- ng_morph_1.createSourceFile(`test/app/app.template.html`, `<app></app>`);
270
- }