index.spec.js 4.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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('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', standalone: false });
  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-routing.module.ts',
  39. '/projects/ng-zorro-top-nav/src/app/pages/welcome/welcome-routing.module.ts',
  40. '/projects/ng-zorro-top-nav/src/app/pages/welcome/welcome.component.ts',
  41. '/projects/ng-zorro-top-nav/src/app/pages/welcome/welcome.component.css',
  42. '/projects/ng-zorro-top-nav/src/app/pages/welcome/welcome.component.html'
  43. ]));
  44. }));
  45. it('should set the style preprocessor correctly', () => __awaiter(void 0, void 0, void 0, function* () {
  46. const options = Object.assign(Object.assign({}, defaultOptions), { style: schema_1.Style.Less });
  47. const tree = yield runner.runSchematic('topnav', options, appTree);
  48. const files = tree.files;
  49. const appContent = (0, get_file_content_1.getFileContent)(tree, '/projects/ng-zorro-top-nav/src/app/app.component.ts');
  50. const welcomeContent = (0, get_file_content_1.getFileContent)(tree, '/projects/ng-zorro-top-nav/src/app/pages/welcome/welcome.component.ts');
  51. expect(appContent).toContain('app.component.less');
  52. expect(welcomeContent).toContain('welcome.component.less');
  53. expect(files).toEqual(jasmine.arrayContaining([
  54. '/projects/ng-zorro-top-nav/src/app/app.component.less',
  55. '/projects/ng-zorro-top-nav/src/app/pages/welcome/welcome.component.less'
  56. ]));
  57. }));
  58. it('should set the prefix correctly', () => __awaiter(void 0, void 0, void 0, function* () {
  59. const options = Object.assign(Object.assign({}, defaultOptions), { prefix: 'nz' });
  60. const tree = yield runner.runSchematic('topnav', options, appTree);
  61. const appContent = (0, get_file_content_1.getFileContent)(tree, '/projects/ng-zorro-top-nav/src/app/app.component.ts');
  62. const welcomeContent = (0, get_file_content_1.getFileContent)(tree, '/projects/ng-zorro-top-nav/src/app/pages/welcome/welcome.component.ts');
  63. expect(appContent).toContain(`selector: 'nz-root'`);
  64. expect(welcomeContent).toContain(`selector: 'nz-welcome'`);
  65. }));
  66. it('should set standalone to be false', () => __awaiter(void 0, void 0, void 0, function* () {
  67. const tree = yield runner.runSchematic('topnav', defaultOptions, appTree);
  68. const appContent = (0, get_file_content_1.getFileContent)(tree, '/projects/ng-zorro-top-nav/src/app/app.component.ts');
  69. const welcomeContent = (0, get_file_content_1.getFileContent)(tree, '/projects/ng-zorro-top-nav/src/app/pages/welcome/welcome.component.ts');
  70. expect(appContent).toContain('standalone: false');
  71. expect(welcomeContent).toContain('standalone: false');
  72. }));
  73. });
  74. //# sourceMappingURL=index.spec.js.map