standalone.spec.js 4.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. "use strict";
  2. /**
  3. * Use of this source code is governed by an MIT-style license that can be
  4. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  5. */
  6. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  7. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  8. return new (P || (P = Promise))(function (resolve, reject) {
  9. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  10. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  11. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  12. step((generator = generator.apply(thisArg, _arguments || [])).next());
  13. });
  14. };
  15. Object.defineProperty(exports, "__esModule", { value: true });
  16. const testing_1 = require("@angular-devkit/schematics/testing");
  17. const schema_1 = require("@schematics/angular/ng-new/schema");
  18. const test_app_1 = require("../../testing/test-app");
  19. const get_file_content_1 = require("../../utils/get-file-content");
  20. describe('[standalone] top-nav schematic', () => {
  21. const defaultOptions = {
  22. project: 'ng-zorro-top-nav',
  23. };
  24. let runner;
  25. let appTree;
  26. beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
  27. runner = new testing_1.SchematicTestRunner('schematics', require.resolve('../../collection.json'));
  28. appTree = yield (0, test_app_1.createTestApp)(runner, { name: 'ng-zorro-top-nav' });
  29. }));
  30. it('should create top-nav files', () => __awaiter(void 0, void 0, void 0, function* () {
  31. const options = Object.assign({}, defaultOptions);
  32. const tree = yield runner.runSchematic('topnav', options, appTree);
  33. const files = tree.files;
  34. expect(files).toEqual(jasmine.arrayContaining([
  35. '/projects/ng-zorro-top-nav/src/app/app.component.html',
  36. '/projects/ng-zorro-top-nav/src/app/app.component.css',
  37. '/projects/ng-zorro-top-nav/src/app/app.component.ts',
  38. '/projects/ng-zorro-top-nav/src/app/app.routes.ts',
  39. '/projects/ng-zorro-top-nav/src/app/pages/welcome/welcome.component.ts',
  40. '/projects/ng-zorro-top-nav/src/app/pages/welcome/welcome.component.css',
  41. '/projects/ng-zorro-top-nav/src/app/pages/welcome/welcome.component.html',
  42. '/projects/ng-zorro-top-nav/src/app/pages/welcome/welcome.routes.ts'
  43. ]));
  44. }));
  45. it('should fall back to the @schematics/angular:component option value', () => __awaiter(void 0, void 0, void 0, function* () {
  46. const options = Object.assign({}, defaultOptions);
  47. const tree = yield runner.runSchematic('topnav', options, appTree);
  48. const appContent = (0, get_file_content_1.getFileContent)(tree, '/projects/ng-zorro-top-nav/src/app/app.component.ts');
  49. expect(tree.exists('/projects/material/src/app/app.module.ts')).toBe(false);
  50. // since v19, the standalone option is removed
  51. expect(appContent).not.toContain('standalone: true');
  52. expect(appContent).toContain('imports: [');
  53. }));
  54. it('should set the style preprocessor correctly', () => __awaiter(void 0, void 0, void 0, function* () {
  55. const options = Object.assign(Object.assign({}, defaultOptions), { style: schema_1.Style.Less });
  56. const tree = yield runner.runSchematic('topnav', options, appTree);
  57. const files = tree.files;
  58. const appContent = (0, get_file_content_1.getFileContent)(tree, '/projects/ng-zorro-top-nav/src/app/app.component.ts');
  59. const welcomeContent = (0, get_file_content_1.getFileContent)(tree, '/projects/ng-zorro-top-nav/src/app/pages/welcome/welcome.component.ts');
  60. expect(appContent).toContain('app.component.less');
  61. expect(welcomeContent).toContain('welcome.component.less');
  62. expect(files).toEqual(jasmine.arrayContaining([
  63. '/projects/ng-zorro-top-nav/src/app/app.component.less',
  64. '/projects/ng-zorro-top-nav/src/app/pages/welcome/welcome.component.less'
  65. ]));
  66. }));
  67. it('should set the prefix correctly', () => __awaiter(void 0, void 0, void 0, function* () {
  68. const options = Object.assign(Object.assign({}, defaultOptions), { prefix: 'nz' });
  69. const tree = yield runner.runSchematic('topnav', options, appTree);
  70. const appContent = (0, get_file_content_1.getFileContent)(tree, '/projects/ng-zorro-top-nav/src/app/app.component.ts');
  71. const welcomeContent = (0, get_file_content_1.getFileContent)(tree, '/projects/ng-zorro-top-nav/src/app/pages/welcome/welcome.component.ts');
  72. expect(appContent).toContain(`selector: 'nz-root'`);
  73. expect(welcomeContent).toContain(`selector: 'nz-welcome'`);
  74. }));
  75. });
  76. //# sourceMappingURL=standalone.spec.js.map