How to use ngModule2 method in ng-mocks

Best JavaScript code snippet using ng-mocks

mock-builder.performance.spec.ts

Source:mock-builder.performance.spec.ts Github

copy

Full Screen

1import {2 Component,3 Directive,4 Injectable,5 InjectionToken,6 NgModule,7} from '@angular/core';8import { ngMocks } from '../mock-helper/mock-helper';9import { MockBuilder } from './mock-builder';10const TARGET1_TOKEN = new InjectionToken('TARGET1');11const TARGET2_TOKEN = new InjectionToken('TARGET2');12@Component({13 selector: 'target1',14 template: 'target1',15})16class Target1Component {}17@Directive({18 selector: '[target1]',19})20class Target1Directive {}21@Injectable()22class Target1Service {}23@NgModule({24 declarations: [Target1Component, Target1Directive],25 providers: [Target1Service],26})27export class Target1Module {}28@Component({29 selector: 'target2',30 template: 'target2',31})32class Target2Component {}33@Directive({34 selector: '[target2]',35})36class Target2Directive {}37@Injectable()38class Target2Service {}39@NgModule({40 declarations: [Target2Component, Target2Directive],41 providers: [Target2Service],42})43export class Target2Module {}44describe('MockBuilderPerformance', () => {45 afterEach(ngMocks.reset);46 it('accepts the same beforeCC', () => {47 const beforeCC = () => undefined;48 const ngModule1 = MockBuilder()49 .mock(Target1Module)50 .beforeCompileComponents(beforeCC)51 .build();52 const ngModule2 = MockBuilder()53 .mock(Target1Module)54 .beforeCompileComponents(beforeCC)55 .build();56 expect(ngModule1.imports?.[0]).toBe(ngModule2.imports?.[0]);57 });58 it('fails on a different size beforeCC', () => {59 const beforeCC = () => undefined;60 const ngModule1 = MockBuilder().mock(Target1Module).build();61 const ngModule2 = MockBuilder()62 .mock(Target1Module)63 .beforeCompileComponents(beforeCC)64 .build();65 expect(ngModule1.imports?.[0]).not.toBe(ngModule2.imports?.[0]);66 });67 it('fails on a missing beforeCC', () => {68 const beforeCC1 = () => undefined;69 const beforeCC2 = () => undefined;70 const ngModule1 = MockBuilder()71 .mock(Target1Module)72 .beforeCompileComponents(beforeCC1)73 .build();74 const ngModule2 = MockBuilder()75 .mock(Target1Module)76 .beforeCompileComponents(beforeCC2)77 .build();78 expect(ngModule1.imports?.[0]).not.toBe(ngModule2.imports?.[0]);79 });80 it('accepts the same keepDef', () => {81 const ngModule1 = MockBuilder().keep(Target1Module).build();82 const ngModule2 = MockBuilder().keep(Target1Module).build();83 expect(ngModule1.imports?.[0]).toBe(ngModule2.imports?.[0]);84 });85 it('fails on a different size keepDef', () => {86 const ngModule1 = MockBuilder().build();87 const ngModule2 = MockBuilder().keep(Target1Module).build();88 expect(ngModule1.imports?.[0]).not.toBe(ngModule2.imports?.[0]);89 });90 it('fails on a missing keepDef', () => {91 const ngModule1 = MockBuilder().keep(Target1Module).build();92 const ngModule2 = MockBuilder().keep(Target2Module).build();93 expect(ngModule1.imports?.[0]).not.toBe(ngModule2.imports?.[0]);94 });95 it('accepts the same replaceDef', () => {96 const ngModule1 = MockBuilder()97 .keep(Target1Module)98 .replace(Target1Component, Target2Component)99 .build();100 const ngModule2 = MockBuilder()101 .keep(Target1Module)102 .replace(Target1Component, Target2Component)103 .build();104 expect(ngModule1.imports?.[0]).toBe(ngModule2.imports?.[0]);105 });106 it('fails on a different size replaceDef', () => {107 const ngModule1 = MockBuilder().keep(Target1Module).build();108 const ngModule2 = MockBuilder()109 .keep(Target1Module)110 .replace(Target1Component, Target2Component)111 .build();112 expect(ngModule1.imports?.[0]).not.toBe(ngModule2.imports?.[0]);113 });114 it('fails on a missing replaceDef', () => {115 const ngModule1 = MockBuilder()116 .keep(Target1Module)117 .replace(Target1Component, Target2Component)118 .build();119 const ngModule2 = MockBuilder()120 .keep(Target1Module)121 .replace(Target1Directive, Target2Directive)122 .build();123 expect(ngModule1.imports?.[0]).not.toBe(ngModule2.imports?.[0]);124 });125 it('accepts the same excludeDef', () => {126 const ngModule1 = MockBuilder()127 .keep(Target1Module)128 .exclude(Target1Component)129 .build();130 const ngModule2 = MockBuilder()131 .keep(Target1Module)132 .exclude(Target1Component)133 .build();134 expect(ngModule1.imports?.[0]).toBe(ngModule2.imports?.[0]);135 });136 it('fails on a different size excludeDef', () => {137 const ngModule1 = MockBuilder().keep(Target1Module).build();138 const ngModule2 = MockBuilder()139 .keep(Target1Module)140 .exclude(Target1Component)141 .build();142 expect(ngModule1.imports?.[0]).not.toBe(ngModule2.imports?.[0]);143 });144 it('fails on a missing excludeDef', () => {145 const ngModule1 = MockBuilder()146 .keep(Target1Module)147 .exclude(Target1Component)148 .build();149 const ngModule2 = MockBuilder()150 .keep(Target1Module)151 .exclude(Target2Component)152 .build();153 expect(ngModule1.imports?.[0]).not.toBe(ngModule2.imports?.[0]);154 });155 it('accepts the same mockDef', () => {156 const ngModule1 = MockBuilder()157 .mock(Target1Module)158 .mock(Target1Component)159 .build();160 const ngModule2 = MockBuilder()161 .mock(Target1Module)162 .mock(Target1Component)163 .build();164 expect(ngModule1.imports?.[0]).toBe(ngModule2.imports?.[0]);165 });166 it('fails on a different size mockDef', () => {167 const ngModule1 = MockBuilder().build();168 const ngModule2 = MockBuilder().mock(Target1Module).build();169 expect(ngModule1.imports?.[0]).not.toBe(ngModule2.imports?.[0]);170 });171 it('fails on a missing mockDef', () => {172 const ngModule1 = MockBuilder().mock(Target1Module).build();173 const ngModule2 = MockBuilder().mock(Target2Module).build();174 expect(ngModule1.imports?.[0]).not.toBe(ngModule2.imports?.[0]);175 });176 it('accepts the same providerDef', () => {177 const ngModule1 = MockBuilder().provide(Target1Service).build();178 const ngModule2 = MockBuilder().provide(Target1Service).build();179 expect(ngModule1.providers?.[0]).toBe(ngModule2.providers?.[0]);180 });181 it('fails on a different size providerDef', () => {182 const ngModule1 = MockBuilder().build();183 const ngModule2 = MockBuilder().provide(Target1Service).build();184 expect(ngModule1.providers?.[0]).not.toBe(185 ngModule2.providers?.[0],186 );187 });188 it('fails on a missing providerDef', () => {189 const ngModule1 = MockBuilder().provide(Target1Service).build();190 const ngModule2 = MockBuilder().provide(Target2Service).build();191 expect(ngModule1.providers?.[0]).not.toBe(192 ngModule2.providers?.[0],193 );194 });195 it('accepts on the same providerDef useValue', () => {196 const ngModule1 = MockBuilder()197 .provide({ provide: Target1Service, useValue: 1 })198 .build();199 const ngModule2 = MockBuilder()200 .provide({ provide: Target1Service, useValue: 1 })201 .build();202 expect(ngModule1.providers?.[0]).toBe(ngModule2.providers?.[0]);203 });204 it('fails on a different providerDef useValue', () => {205 const ngModule1 = MockBuilder()206 .provide({ provide: Target1Service, useValue: 1 })207 .build();208 const ngModule2 = MockBuilder()209 .provide({ provide: Target1Service, useValue: 2 })210 .build();211 expect(ngModule1.providers?.[0]).not.toBe(212 ngModule2.providers?.[0],213 );214 });215 it('accepts the same providerDef useValue', () => {216 const ngModule1 = MockBuilder()217 .provide({ provide: Target1Service, useClass: Target2Service })218 .build();219 const ngModule2 = MockBuilder()220 .provide({ provide: Target1Service, useClass: Target2Service })221 .build();222 expect(ngModule1.providers?.[0]).toBe(ngModule2.providers?.[0]);223 });224 it('fails on a different providerDef useValue', () => {225 const ngModule1 = MockBuilder()226 .provide({ provide: Target1Service, useClass: Target1Service })227 .build();228 const ngModule2 = MockBuilder()229 .provide({ provide: Target1Service, useClass: Target2Service })230 .build();231 expect(ngModule1.providers?.[0]).not.toBe(232 ngModule2.providers?.[0],233 );234 });235 it('accepts the same providerDef helperUseFactory', () => {236 const factory = () => 1;237 const ngModule1 = MockBuilder()238 .provide({ provide: Target1Service, useFactory: factory })239 .build();240 const ngModule2 = MockBuilder()241 .provide({ provide: Target1Service, useFactory: factory })242 .build();243 expect(ngModule1.providers?.[0]).toBe(ngModule2.providers?.[0]);244 });245 it('fails on a different providerDef helperUseFactory', () => {246 const ngModule1 = MockBuilder()247 .provide({ provide: Target1Service, useFactory: () => 1 })248 .build();249 const ngModule2 = MockBuilder()250 .provide({ provide: Target1Service, useFactory: () => 2 })251 .build();252 expect(ngModule1.providers?.[0]).not.toBe(253 ngModule2.providers?.[0],254 );255 });256 it('accepts the same providerDef useExisting', () => {257 const ngModule1 = MockBuilder()258 .provide({259 provide: Target1Service,260 useExisting: Target2Service,261 })262 .build();263 const ngModule2 = MockBuilder()264 .provide({265 provide: Target1Service,266 useExisting: Target2Service,267 })268 .build();269 expect(ngModule1.providers?.[0]).toBe(ngModule2.providers?.[0]);270 });271 it('fails on a different providerDef useExisting', () => {272 const ngModule1 = MockBuilder()273 .provide({274 provide: Target1Service,275 useExisting: Target1Service,276 })277 .build();278 const ngModule2 = MockBuilder()279 .provide({280 provide: Target1Service,281 useExisting: Target2Service,282 })283 .build();284 expect(ngModule1.providers?.[0]).not.toBe(285 ngModule2.providers?.[0],286 );287 });288 it('accepts the same providerDef', () => {289 const def = { provide: Target1Service };290 const ngModule1 = MockBuilder().provide(def).build();291 const ngModule2 = MockBuilder().provide(def).build();292 expect(ngModule1.providers?.[0]).toBe(ngModule2.providers?.[0]);293 });294 it('fails on a different providerDef', () => {295 const ngModule1 = MockBuilder()296 .provide({ provide: Target1Service })297 .build();298 const ngModule2 = MockBuilder()299 .provide({ provide: Target1Service })300 .build();301 expect(ngModule1.providers?.[0]).not.toBe(302 ngModule2.providers?.[0],303 );304 });305 it('fails on a different multi flags', () => {306 const ngModule1 = MockBuilder()307 .provide({ provide: Target1Service, useValue: 1 })308 .build();309 const ngModule2 = MockBuilder()310 .provide({ provide: Target1Service, useValue: 1, multi: true })311 .build();312 expect(ngModule1.providers?.[0]).not.toBe(313 ngModule2.providers?.[0],314 );315 });316 it('accepts the same multi flags', () => {317 const ngModule1 = MockBuilder()318 .provide({ provide: Target1Service, useValue: 1, multi: true })319 .build();320 const ngModule2 = MockBuilder()321 .provide({ provide: Target1Service, useValue: 1, multi: true })322 .build();323 expect(ngModule1.providers?.[0]).toBe(ngModule2.providers?.[0]);324 });325 it('fails on a different multi size', () => {326 const ngModule1 = MockBuilder()327 .provide({ provide: Target1Service, useValue: 1, multi: true })328 .build();329 const ngModule2 = MockBuilder()330 .provide({ provide: Target1Service, useValue: 1, multi: true })331 .provide({ provide: Target1Service, useValue: 2, multi: true })332 .build();333 expect(ngModule1.providers?.[0]).not.toBe(334 ngModule2.providers?.[0],335 );336 });337 it('fails on a different multi values', () => {338 const ngModule1 = MockBuilder()339 .provide({ provide: Target1Service, useValue: 1, multi: true })340 .build();341 const ngModule2 = MockBuilder()342 .provide({ provide: Target1Service, useValue: 2, multi: true })343 .build();344 expect(ngModule1.providers?.[0]).not.toBe(345 ngModule2.providers?.[0],346 );347 });348 it('accepts the same defProviders', () => {349 const ngModule1 = MockBuilder()350 .keep({351 ngModule: Target1Module,352 providers: [353 {354 provides: TARGET1_TOKEN,355 useValue: 1,356 },357 ],358 })359 .build();360 const ngModule2 = MockBuilder()361 .keep({362 ngModule: Target1Module,363 providers: [364 {365 provides: TARGET1_TOKEN,366 useValue: 1,367 },368 ],369 })370 .build();371 expect(ngModule1.imports?.[0]).toBe(ngModule2.imports?.[0]);372 });373 it('fails on a different size defProviders', () => {374 const ngModule1 = MockBuilder().keep(Target1Module).build();375 const ngModule2 = MockBuilder()376 .keep({377 ngModule: Target1Module,378 providers: [379 {380 provides: TARGET1_TOKEN,381 useValue: 1,382 },383 ],384 })385 .build();386 expect(ngModule1.imports?.[0]).not.toBe(ngModule2.imports?.[0]);387 });388 it('fails on a missing defProviders', () => {389 const ngModule1 = MockBuilder()390 .keep(Target2Module)391 .keep({392 ngModule: Target1Module,393 providers: [394 {395 provides: TARGET2_TOKEN,396 useValue: 1,397 },398 ],399 })400 .build();401 const ngModule2 = MockBuilder()402 .keep(Target1Module)403 .keep({404 ngModule: Target2Module,405 providers: [406 {407 provides: TARGET2_TOKEN,408 useValue: 1,409 },410 ],411 })412 .build();413 expect(ngModule1.imports?.[0]).not.toBe(ngModule2.imports?.[0]);414 });415 it('fails on a different defProviders', () => {416 const ngModule1 = MockBuilder()417 .keep({418 ngModule: Target1Module,419 providers: [420 {421 provides: TARGET1_TOKEN,422 useValue: 1,423 },424 ],425 })426 .build();427 const ngModule2 = MockBuilder()428 .keep({429 ngModule: Target1Module,430 providers: [431 {432 provides: TARGET1_TOKEN,433 useValue: 2,434 },435 ],436 })437 .build();438 expect(ngModule1.imports?.[0]).not.toBe(ngModule2.imports?.[0]);439 });440 it('fails on the same defProviders but different multi', () => {441 const ngModule1 = MockBuilder()442 .keep({443 ngModule: Target1Module,444 providers: [445 {446 multi: true,447 provides: TARGET1_TOKEN,448 useValue: 1,449 },450 ],451 })452 .build();453 const ngModule2 = MockBuilder()454 .keep({455 ngModule: Target1Module,456 providers: [457 {458 provides: TARGET1_TOKEN,459 useValue: 1,460 },461 ],462 })463 .build();464 expect(ngModule1.imports?.[0]).not.toBe(ngModule2.imports?.[0]);465 });466 it('accepts the same defValue', () => {467 const ngModule1 = MockBuilder()468 .mock(Target1Module)469 .mock(Target1Service, 1)470 .build();471 const ngModule2 = MockBuilder()472 .mock(Target1Module)473 .mock(Target1Service, 1)474 .build();475 expect(ngModule1.providers?.[0]).toBe(ngModule2.providers?.[0]);476 });477 it('fails on a different size defValue', () => {478 const ngModule1 = MockBuilder()479 .mock(Target1Module)480 .mock(Target1Service)481 .build();482 const ngModule2 = MockBuilder()483 .mock(Target1Module)484 .mock(Target1Service, 1)485 .build();486 expect(ngModule1.providers?.[0]).not.toBe(487 ngModule2.providers?.[0],488 );489 });490 it('fails on a missing defValue', () => {491 const ngModule1 = MockBuilder()492 .mock(Target1Module)493 .mock(Target1Service)494 .mock(Target2Service, 2)495 .build();496 const ngModule2 = MockBuilder()497 .mock(Target1Module)498 .mock(Target2Service)499 .mock(Target1Service, 1)500 .build();501 expect(ngModule1.providers?.[0]).not.toBe(502 ngModule2.providers?.[0],503 );504 });505 it('fails on a different defValue', () => {506 const ngModule1 = MockBuilder()507 .mock(Target1Module)508 .mock(Target1Service, 1)509 .build();510 const ngModule2 = MockBuilder()511 .mock(Target1Module)512 .mock(Target1Service, 2)513 .build();514 expect(ngModule1.providers?.[0]).not.toBe(515 ngModule2.providers?.[0],516 );517 });518 it('accepts the same size configDef', () => {519 const ngModule1 = MockBuilder().keep(Target1Module, {}).build();520 const ngModule2 = MockBuilder().keep(Target1Module, {}).build();521 expect(ngModule1.providers?.[0]).toBe(ngModule2.providers?.[0]);522 });523 it('fails on a different size configDef', () => {524 const ngModule1 = MockBuilder().keep(Target1Module).build();525 const ngModule2 = MockBuilder()526 .keep(Target1Module, { dependency: true })527 .build();528 expect(ngModule1.providers?.[0]).not.toBe(529 ngModule2.providers?.[0],530 );531 });532 it('fails on a missing configDef', () => {533 const ngModule1 = MockBuilder()534 .keep(Target1Module)535 .keep(Target2Module, { dependency: true })536 .build();537 const ngModule2 = MockBuilder()538 .keep(Target2Module)539 .keep(Target1Module, { dependency: true })540 .build();541 expect(ngModule1.providers?.[0]).not.toBe(542 ngModule2.providers?.[0],543 );544 });545 it('accepts the same configDef', () => {546 const config = {};547 const ngModule1 = MockBuilder()548 .keep(Target1Module, config)549 .build();550 const ngModule2 = MockBuilder()551 .keep(Target1Module, config)552 .build();553 expect(ngModule1.providers?.[0]).toBe(ngModule2.providers?.[0]);554 });555 it('fails on different dependency configDef', () => {556 const ngModule1 = MockBuilder()557 .keep(Target1Module, { dependency: true })558 .build();559 const ngModule2 = MockBuilder()560 .keep(Target1Module, { dependency: false })561 .build();562 expect(ngModule1.providers?.[0]).not.toBe(563 ngModule2.providers?.[0],564 );565 });566 it('fails on different export configDef', () => {567 const ngModule1 = MockBuilder()568 .keep(Target1Module, { export: true })569 .build();570 const ngModule2 = MockBuilder()571 .keep(Target1Module, { export: false })572 .build();573 expect(ngModule1.providers?.[0]).not.toBe(574 ngModule2.providers?.[0],575 );576 });577 it('fails on different exportAll configDef', () => {578 const ngModule1 = MockBuilder()579 .keep(Target1Module, { exportAll: true })580 .build();581 const ngModule2 = MockBuilder()582 .keep(Target1Module, { exportAll: false })583 .build();584 expect(ngModule1.providers?.[0]).not.toBe(585 ngModule2.providers?.[0],586 );587 });588 it('accepts the same render configDef', () => {589 const render = {};590 const ngModule1 = MockBuilder()591 .mock(Target1Module, { render })592 .build();593 const ngModule2 = MockBuilder()594 .mock(Target1Module, { render })595 .build();596 expect(ngModule1.providers?.[0]).toBe(ngModule2.providers?.[0]);597 });598 it('fails on different render flag configDef', () => {599 const ngModule1 = MockBuilder()600 .mock(Target1Module, { render: true })601 .build();602 const ngModule2 = MockBuilder()603 .mock(Target1Module, { render: false })604 .build();605 expect(ngModule1.providers?.[0]).not.toBe(606 ngModule2.providers?.[0],607 );608 });609 it('fails on different render length configDef', () => {610 const ngModule1 = MockBuilder()611 .mock(Target1Module, { render: {} })612 .build();613 const ngModule2 = MockBuilder()614 .mock(Target1Module, {615 render: {616 variables: {},617 },618 })619 .build();620 expect(ngModule1.providers?.[0]).not.toBe(621 ngModule2.providers?.[0],622 );623 });624 it('fails on different render.$implicit configDef', () => {625 const ngModule1 = MockBuilder()626 .mock(Target1Module, {627 render: {628 $implicit: true,629 },630 })631 .build();632 const ngModule2 = MockBuilder()633 .mock(Target1Module, {634 render: {635 $implicit: false,636 },637 })638 .build();639 expect(ngModule1.providers?.[0]).not.toBe(640 ngModule2.providers?.[0],641 );642 });643 it('accepts the same render.variables configDef', () => {644 const variables = {};645 const ngModule1 = MockBuilder()646 .mock(Target1Module, {647 render: {648 variables,649 },650 })651 .build();652 const ngModule2 = MockBuilder()653 .mock(Target1Module, {654 render: {655 variables,656 },657 })658 .build();659 expect(ngModule1.providers?.[0]).toBe(ngModule2.providers?.[0]);660 });661 it('accepts equal render.variables configDef', () => {662 const ngModule1 = MockBuilder()663 .mock(Target1Module, {664 render: {665 variables: {666 flag: 1,667 },668 },669 })670 .build();671 const ngModule2 = MockBuilder()672 .mock(Target1Module, {673 render: {674 variables: {675 flag: 1,676 },677 },678 })679 .build();680 expect(ngModule1.providers?.[0]).toBe(ngModule2.providers?.[0]);681 });682 it('fails on missing definition configDef', () => {683 const ngModule1 = MockBuilder()684 .mock(Target1Module, { render: {} })685 .build();686 const ngModule2 = MockBuilder()687 .mock(Target1Module, {688 render: {689 variables: {690 flag: 2,691 },692 },693 })694 .build();695 const ngModule3 = MockBuilder()696 .mock(Target1Module, { render: {} })697 .build();698 expect(ngModule1.providers?.[0]).not.toBe(699 ngModule2.providers?.[0],700 );701 expect(ngModule2.providers?.[0]).not.toBe(702 ngModule3.providers?.[0],703 );704 });705 it('fails on different render.variables configDef', () => {706 const ngModule1 = MockBuilder()707 .mock(Target1Module, {708 render: {709 variables: {710 flag: 1,711 },712 },713 })714 .build();715 const ngModule2 = MockBuilder()716 .mock(Target1Module, {717 render: {718 variables: {719 flag: 1,720 key: false,721 },722 },723 })724 .build();725 expect(ngModule1.providers?.[0]).not.toBe(726 ngModule2.providers?.[0],727 );728 });729 it('fails on different values in render.variables configDef', () => {730 const ngModule1 = MockBuilder()731 .mock(Target1Module, {732 render: {733 variables: {734 flag: 1,735 },736 },737 })738 .build();739 const ngModule2 = MockBuilder()740 .mock(Target1Module, {741 render: {742 variables: {743 flag: 2,744 },745 },746 })747 .build();748 expect(ngModule1.providers?.[0]).not.toBe(749 ngModule2.providers?.[0],750 );751 });752 it('fails on different amount of blocks in render configDef', () => {753 const ngModule1 = MockBuilder()754 .mock(Target1Module, {755 render: {756 block1: {},757 },758 })759 .build();760 const ngModule2 = MockBuilder()761 .mock(Target1Module, {762 render: {763 block1: {},764 block2: {},765 },766 })767 .build();768 expect(ngModule1.providers?.[0]).not.toBe(769 ngModule2.providers?.[0],770 );771 });772 it('fails on different block definitions in render configDef', () => {773 const ngModule1 = MockBuilder()774 .mock(Target1Module, {775 render: {776 block1: {777 $implicit: true,778 },779 },780 })781 .build();782 const ngModule2 = MockBuilder()783 .mock(Target1Module, {784 render: {785 block1: {786 $implicit: false,787 },788 },789 })790 .build();791 expect(ngModule1.providers?.[0]).not.toBe(792 ngModule2.providers?.[0],793 );794 });...

Full Screen

Full Screen

processNgModuleDocs.spec.js

Source:processNgModuleDocs.spec.js Github

copy

Full Screen

1const testPackage = require('../../helpers/test-package');2const Dgeni = require('dgeni');3describe('processNgModuleDocs processor', () => {4 let processor;5 let injector;6 beforeEach(() => {7 const dgeni = new Dgeni([testPackage('angular-api-package')]);8 injector = dgeni.configureInjector();9 processor = injector.get('processNgModuleDocs');10 });11 it('should be available on the injector', () => {12 expect(processor.$process).toBeDefined();13 });14 it('should run before the correct processor', () => {15 expect(processor.$runBefore).toEqual(['createSitemap']);16 });17 it('should run after the correct processor', () => {18 expect(processor.$runAfter).toEqual(['extractDecoratedClassesProcessor', 'computeIdsProcessor']);19 });20 it('should convert non-array NgModule options to arrays', () => {21 const docs = [{22 docType: 'ngmodule',23 ngmoduleOptions: {24 a: ['AAA'],25 b: 'BBB',26 c: 4227 }28 }];29 processor.$process(docs);30 expect(docs[0].ngmoduleOptions.a).toEqual(['AAA']);31 expect(docs[0].ngmoduleOptions.b).toEqual(['BBB']);32 expect(docs[0].ngmoduleOptions.c).toEqual([42]);33 });34 it('should link directive/pipe docs with their NgModule docs (sorted by id)', () => {35 const aliasMap = injector.get('aliasMap');36 const directiveOptions = { selector: 'some-selector' };37 const ngModule1 = { docType: 'ngmodule', id: 'NgModule1', aliases: ['NgModule1'], ngmoduleOptions: {} };38 const ngModule2 = { docType: 'ngmodule', id: 'NgModule2', aliases: ['NgModule2'], ngmoduleOptions: {} };39 const directive1 = { docType: 'directive', id: 'Directive1', ngModules: ['NgModule1'], directiveOptions };40 const directive2 = { docType: 'directive', id: 'Directive2', ngModules: ['NgModule2'], directiveOptions };41 const directive3 = { docType: 'directive', id: 'Directive3', ngModules: ['NgModule1', 'NgModule2'], directiveOptions };42 const pipe1 = { docType: 'pipe', id: 'Pipe1', ngModules: ['NgModule1'] };43 const pipe2 = { docType: 'pipe', id: 'Pipe2', ngModules: ['NgModule2'] };44 const pipe3 = { docType: 'pipe', id: 'Pipe3', ngModules: ['NgModule1', 'NgModule2'] };45 aliasMap.addDoc(ngModule1);46 aliasMap.addDoc(ngModule2);47 processor.$process([ngModule1, pipe2, directive2, directive3, pipe1, ngModule2, directive1, pipe3]);48 expect(ngModule1.directives).toEqual([directive1, directive3]);49 expect(ngModule1.pipes).toEqual([pipe1, pipe3]);50 expect(ngModule2.directives).toEqual([directive2, directive3]);51 expect(ngModule2.pipes).toEqual([pipe2, pipe3]);52 expect(directive1.ngModules).toEqual([ngModule1]);53 expect(directive2.ngModules).toEqual([ngModule2]);54 expect(directive3.ngModules).toEqual([ngModule1, ngModule2]);55 expect(pipe1.ngModules).toEqual([ngModule1]);56 expect(pipe2.ngModules).toEqual([ngModule2]);57 expect(pipe3.ngModules).toEqual([ngModule1, ngModule2]);58 });59 it('should link classes that have a `providedIn` property on an @Injectable decorator that references a known NgModule doc', () => {60 const ngModule1 = { docType: 'ngmodule', id: 'NgModule1', aliases: ['NgModule1'], ngmoduleOptions: {} };61 const ngModule2 = { docType: 'ngmodule', id: 'NgModule2', aliases: ['NgModule2'], ngmoduleOptions: {} };62 const injectable1 = { docType: 'class', name: 'Injectable1', decorators: [{ name: 'Injectable', argumentInfo: [{ providedIn: '\'root\'' }] }] };63 const injectable2 = { docType: 'class', name: 'Injectable2', decorators: [{ name: 'Injectable', argumentInfo: [{ providedIn: '\'platform\'' }] }] };64 const injectable3 = { docType: 'class', name: 'Injectable3', decorators: [{ name: 'Injectable', argumentInfo: [{ providedIn: '"root"' }] }] };65 const injectable4 = { docType: 'class', name: 'Injectable4', decorators: [{ name: 'Injectable', argumentInfo: [{ providedIn: '"platform"' }] }] };66 const injectable5 = { docType: 'class', name: 'Injectable5', decorators: [{ name: 'Injectable', argumentInfo: [{ providedIn: 'NgModule1' }] }] };67 const injectable6 = { docType: 'class', name: 'Injectable6', decorators: [{ name: 'Injectable', argumentInfo: [{ providedIn: 'NgModule2' }] }] };68 const injectable7 = { docType: 'class', name: 'Injectable7' };69 const nonInjectable = { docType: 'class', name: 'nonInjectable' };70 const aliasMap = injector.get('aliasMap');71 aliasMap.addDoc(ngModule1);72 aliasMap.addDoc(ngModule2);73 processor.$process([ngModule1, ngModule2, injectable1, injectable2, injectable3, injectable4, injectable5, injectable6, injectable7, nonInjectable]);74 expect(ngModule1.providers).toEqual(['{ provide: Injectable5, useClass: Injectable5 }']);75 expect(ngModule2.providers).toEqual(['{ provide: Injectable6, useClass: Injectable6 }']);76 expect(injectable1.ngModules).toEqual(['root']);77 expect(injectable2.ngModules).toEqual(['platform']);78 expect(injectable3.ngModules).toEqual(['root']);79 expect(injectable4.ngModules).toEqual(['platform']);80 expect(injectable5.ngModules).toEqual([ngModule1]);81 expect(injectable6.ngModules).toEqual([ngModule2]);82 expect(injectable7.ngModules).toBeUndefined();83 expect(nonInjectable.ngModules).toBeUndefined();84 });85 it('should link classes that have a `providedIn` property on a ɵprov static that references a known NgModule doc', () => {86 const ngModule1 = { docType: 'ngmodule', id: 'NgModule1', aliases: ['NgModule1'], ngmoduleOptions: {} };87 const ngModule2 = { docType: 'ngmodule', id: 'NgModule2', aliases: ['NgModule2'], ngmoduleOptions: {} };88 const injectable1 = { docType: 'class', name: 'Injectable1', symbol: createSymbolWithProvider('\'root\'') };89 const injectable2 = { docType: 'class', name: 'Injectable2', symbol: createSymbolWithProvider('\'platform\'') };90 const injectable3 = { docType: 'class', name: 'Injectable3', symbol: createSymbolWithProvider('"root"') };91 const injectable4 = { docType: 'class', name: 'Injectable4', symbol: createSymbolWithProvider('"platform"') };92 const injectable5 = { docType: 'class', name: 'Injectable5', symbol: createSymbolWithProvider('NgModule1') };93 const injectable6 = { docType: 'class', name: 'Injectable6', symbol: createSymbolWithProvider('NgModule2') };94 const injectable7 = { docType: 'class', name: 'Injectable7' };95 const nonInjectable = { docType: 'class', name: 'nonInjectable' };96 const aliasMap = injector.get('aliasMap');97 aliasMap.addDoc(ngModule1);98 aliasMap.addDoc(ngModule2);99 processor.$process([ngModule1, ngModule2, injectable1, injectable2, injectable3, injectable4, injectable5, injectable6, injectable7, nonInjectable]);100 expect(ngModule1.providers).toEqual(['{ provide: Injectable5, useClass: Injectable5 }']);101 expect(ngModule2.providers).toEqual(['{ provide: Injectable6, useClass: Injectable6 }']);102 expect(injectable1.ngModules).toEqual(['root']);103 expect(injectable2.ngModules).toEqual(['platform']);104 expect(injectable3.ngModules).toEqual(['root']);105 expect(injectable4.ngModules).toEqual(['platform']);106 expect(injectable5.ngModules).toEqual([ngModule1]);107 expect(injectable6.ngModules).toEqual([ngModule2]);108 expect(injectable7.ngModules).toBeUndefined();109 expect(nonInjectable.ngModules).toBeUndefined();110 });111 it('should link injectables that are marked with `@ngModule` JSDOC tags', () => {112 const ngModule1 = { docType: 'ngmodule', id: 'NgModule1', aliases: ['NgModule1'], ngmoduleOptions: {} };113 const ngModule2 = { docType: 'ngmodule', id: 'NgModule2', aliases: ['NgModule2'], ngmoduleOptions: { providers: ['PROVIDER'] } };114 const injectable1 = { docType: 'class', name: 'Injectable1', ngModules: ['NgModule1'] };115 const injectable2 = { docType: 'class', name: 'Injectable2', ngModules: ['NgModule2'] };116 const injectable3 = { docType: 'class', name: 'Injectable3' };117 const nonInjectable = { docType: 'class', name: 'nonInjectable' };118 const aliasMap = injector.get('aliasMap');119 aliasMap.addDoc(ngModule1);120 aliasMap.addDoc(ngModule2);121 processor.$process([ngModule1, ngModule2, injectable1, injectable2, injectable3, nonInjectable]);122 // Should not update the NgModule docs in this case.123 expect(ngModule1.providers).toBeUndefined();124 expect(ngModule2.providers).toEqual(['PROVIDER']);125 expect(injectable1.ngModules).toEqual([ngModule1]);126 expect(injectable2.ngModules).toEqual([ngModule2]);127 expect(injectable3.ngModules).toBeUndefined();128 expect(nonInjectable.ngModules).toBeUndefined();129 });130 it('should link injectables that are parsed out of `@NgModule` decorators', () => {131 const ngModule1 = { docType: 'ngmodule', id: 'NgModule1', ngmoduleOptions: { providers: ['Injectable1', '{ provide: Injectable2, useClass: Injectable2 }'] } };132 const ngModule2 = { docType: 'ngmodule', id: 'NgModule2', ngmoduleOptions: { providers: ['{ provide: Injectable3, useValue: {} }'] } };133 const injectable1 = { docType: 'class', name: 'Injectable1', aliases: ['Injectable1'] };134 const injectable2 = { docType: 'class', name: 'Injectable2', aliases: ['Injectable2'] };135 const injectable3 = { docType: 'class', name: 'Injectable3', aliases: ['Injectable3'] };136 const aliasMap = injector.get('aliasMap');137 aliasMap.addDoc(injectable1);138 aliasMap.addDoc(injectable2);139 aliasMap.addDoc(injectable3);140 processor.$process([ngModule1, ngModule2, injectable1, injectable2, injectable3]);141 expect(injectable1.ngModules).toEqual([ngModule1]);142 expect(injectable2.ngModules).toEqual([ngModule1]);143 expect(injectable3.ngModules).toEqual([ngModule2]);144 });145 it('should error if an injectable that has a `providedIn` property that references an unknown NgModule doc', () => {146 const log = injector.get('log');147 const injectable = { docType: 'class', name: 'Injectable1', decorators: [{ name: 'Injectable', argumentInfo: [{ providedIn: 'NgModuleRef' }] }] };148 expect(() => {149 processor.$process([injectable]);150 }).toThrowError('Failed to process NgModule relationships.');151 expect(log.error).toHaveBeenCalledWith(152 'The referenced "NgModuleRef" does not match a public NgModule - doc "Injectable1" (class) ');153 });154 it('should error if an injectable that has a `providedIn` property that references an ambiguous NgModule doc', () => {155 const log = injector.get('log');156 const ngModule1 = { docType: 'ngmodule', id: 'NgModule1', aliases: ['NgModuleRef'], ngmoduleOptions: {} };157 const ngModule2 = { docType: 'ngmodule', id: 'NgModule2', aliases: ['NgModuleRef'], ngmoduleOptions: {} };158 const injectable = { docType: 'class', name: 'Injectable1', decorators: [{ name: 'Injectable', argumentInfo: [{ providedIn: 'NgModuleRef' }] }] };159 const aliasMap = injector.get('aliasMap');160 aliasMap.addDoc(ngModule1);161 aliasMap.addDoc(ngModule2);162 expect(() => {163 processor.$process([injectable]);164 }).toThrowError('Failed to process NgModule relationships.');165 expect(log.error).toHaveBeenCalledWith(166 'The referenced "NgModuleRef" is ambiguous. Matches: NgModule1, NgModule2 - doc "Injectable1" (class) ');167 });168 it('should not error if an abstract directive does not have a `@ngModule` tag', () => {169 expect(() => {170 processor.$process([{ docType: 'directive', id: 'AbstractDir', directiveOptions: {} }]);171 }).not.toThrow();172 expect(() => {173 processor.$process([{174 docType: 'directive', id: 'AbstractDir',175 directiveOptions: { selector: undefined }176 }]);177 }).not.toThrow();178 });179 it('should error if a pipe/directive does not have a `@ngModule` tag', () => {180 const log = injector.get('log');181 expect(() => {182 processor.$process([{183 docType: 'directive', id: 'Directive1',184 directiveOptions: { selector: 'dir1' }185 }]);186 }).toThrowError('Failed to process NgModule relationships.');187 expect(log.error).toHaveBeenCalledWith(188 '"Directive1" has no @ngModule tag. Docs of type "directive" must have this tag. - doc "Directive1" (directive) ');189 expect(() => {190 processor.$process([{ docType: 'pipe', id: 'Pipe1' }]);191 }).toThrowError('Failed to process NgModule relationships.');192 expect(log.error).toHaveBeenCalledWith(193 '"Pipe1" has no @ngModule tag. Docs of type "pipe" must have this tag. - doc "Pipe1" (pipe) ');194 });195 it('should error if a pipe/directive has an @ngModule tag that does not match an NgModule doc', () => {196 const log = injector.get('log');197 expect(() => {198 processor.$process([{199 docType: 'directive', id: 'Directive1', ngModules: ['MissingNgModule'],200 directiveOptions: { selector: 'dir1' }201 }]);202 }).toThrowError('Failed to process NgModule relationships.');203 expect(log.error).toHaveBeenCalledWith(204 'The referenced "MissingNgModule" does not match a public NgModule - doc "Directive1" (directive) ');205 expect(() => {206 processor.$process([{ docType: 'pipe', id: 'Pipe1', ngModules: ['MissingNgModule'] }]);207 }).toThrowError('Failed to process NgModule relationships.');208 expect(log.error).toHaveBeenCalledWith(209 'The referenced "MissingNgModule" does not match a public NgModule - doc "Pipe1" (pipe) ');210 });211 it('should error if a pipe/directive has an @ngModule tag that matches more than one NgModule doc', () => {212 const aliasMap = injector.get('aliasMap');213 const log = injector.get('log');214 const ngModule1 = { docType: 'ngmodule', id: 'NgModule1', aliases: ['NgModuleAlias'], ngmoduleOptions: {} };215 const ngModule2 = { docType: 'ngmodule', id: 'NgModule2', aliases: ['NgModuleAlias'], ngmoduleOptions: {} };216 aliasMap.addDoc(ngModule1);217 aliasMap.addDoc(ngModule2);218 expect(() => {219 processor.$process([{220 docType: 'directive', id: 'Directive1', ngModules: ['NgModuleAlias'],221 directiveOptions: { selector: 'dir1' }222 }]);223 }).toThrowError('Failed to process NgModule relationships.');224 expect(log.error).toHaveBeenCalledWith(225 'The referenced "NgModuleAlias" is ambiguous. Matches: NgModule1, NgModule2 - doc "Directive1" (directive) ');226 expect(() => {227 processor.$process([{ docType: 'pipe', id: 'Pipe1', ngModules: ['NgModuleAlias'] }]);228 }).toThrowError('Failed to process NgModule relationships.');229 expect(log.error).toHaveBeenCalledWith(230 'The referenced "NgModuleAlias" is ambiguous. Matches: NgModule1, NgModule2 - doc "Pipe1" (pipe) ');231 });232});233/**234 * This function simulates a TypeScript AST node for the code:235 *236 * ```237 * static ɵprov = ɵɵdefineInjectable({238 * providedIn: 'xxxx',239 * });240 * ```241 */242function createSymbolWithProvider(providedIn) {243 const initializer = {244 pos: 0,245 end: providedIn.length,246 getSourceFile() {247 return { text: providedIn };248 }249 };250 const valueDeclaration = { initializer: { arguments: [{ properties: [{ name: { text: 'providedIn' }, initializer }] }] } };251 const exportMap = new Map();252 exportMap.set('ɵprov', { valueDeclaration });253 return { exports: exportMap };...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { ngModule2 } from 'ng-mocks';2import { ngMocks } from 'ng-mocks';3import { ngMocksUniverse } from 'ng-mocks';4import { ngMocksGuts } from 'ng-mocks';5import { ngMocksFormat } from 'ng-mocks';6import { ngMocksDeps } from 'ng-mocks';7import { ngMocksGlobal } from 'ng-mocks';8import { ngMocksFlush } from 'ng-mocks';9import { ngMocksStruck } from 'ng-mocks';10import { ngMocksDefault } from 'ng-mocks';11import { ngMocksInput } from 'ng-mocks';12import { ngMocksOutput } from 'ng-mocks';13import { ngMocksFind } from 'ng-mocks';14import { ngMocksFlush } from 'ng-mocks';15import { ngMocksStruck } from 'ng-mocks';16import { ngMocksDefault } from 'ng-mocks';17import { ngMocksInput } from 'ng-mocks';18import { ngMocksOutput } from 'ng-mocks';19import { ngMocksFind } from 'ng-mocks';20import { ngMocksFlush } from 'ng-mocks';

Full Screen

Using AI Code Generation

copy

Full Screen

1import { ngModule2 } from 'ng-mocks';2import { AppModule } from './app.module';3describe('AppComponent', () => {4 ngModule2(AppModule);5 it('should create the app', () => {6 const fixture = TestBed.createComponent(AppComponent);7 const app = fixture.debugElement.componentInstance;8 expect(app).toBeTruthy();9 });10});11import { ngMocks } from 'ng-mocks';12import { AppModule } from './app.module';13describe('AppComponent', () => {14 ngMocks.get(AppModule);15 it('should create the app', () => {16 const app = ngMocks.get(AppComponent);17 expect(app).toBeTruthy();18 });19});20import { ngMocks } from 'ng-mocks';21import { AppModule } from './app.module';22describe('AppComponent', () => {23 ngMocks.get(AppModule);24 it('should create the app', () => {25 const app = ngMocks.find('app-root');26 expect(app).toBeTruthy();27 });28});29import { ngMocks } from 'ng-mocks';30import { AppModule } from './app.module';31describe('AppComponent', () => {32 ngMocks.get(AppModule);33 it('should create the app', () => {34 const app = ngMocks.findInstance(AppComponent);35 expect(app).toBeTruthy();36 });37});

Full Screen

Using AI Code Generation

copy

Full Screen

1import {ngModule2} from 'ng-mocks';2import {MyModule} from './my-module';3import {MyComponent} from './my-component';4import {MyService} from './my-service';5describe('MyComponent', () => {6 it('should work', () => {7 const fixture = ngModule2(MyModule, MyComponent);8 fixture.detectChanges();9 expect(fixture.componentInstance).toBeTruthy();10 });11});12import {NgModule} from '@angular/core';13import {MyComponent} from './my-component';14import {MyService} from './my-service';15@NgModule({16})17export class MyModule {}18import {Component, Inject} from '@angular/core';19import {MyService} from './my-service';20@Component({21})22export class MyComponent {23 constructor(@Inject(MyService) public readonly service: MyService) {}24}25import {Injectable} from '@angular/core';26@Injectable()27export class MyService {}

Full Screen

Using AI Code Generation

copy

Full Screen

1import { ngModule2 } from 'ng-mocks';2import { ngMocks } from 'ng-mocks';3import { ngMocks } from 'ng-mocks';4import { ngMocks } from 'ng-mocks';5import { ngMocks } from 'ng-mocks';6import { ngMocks } from 'ng-mocks';7import { ngMocks } from 'ng-mocks';8import { ngMocks } from 'ng-mocks';9import { ngMocks } from 'ng-mocks';10import { ngMocks } from 'ng-mocks';11import { ngMocks } from 'ng-mocks';12import { ngMocks } from 'ng-mocks';13import { ngMocks } from 'ng-mocks';14import { ngMocks } from 'ng-mocks';15import { ngMocks } from 'ng-mocks';16import { ngMocks } from 'ng-mocks';17import { ngMocks } from 'ng-mocks';18import { ngMocks } from 'ng-mocks';19import { ngMocks } from 'ng-mocks';20import { ngMocks } from 'ng-mocks

Full Screen

Using AI Code Generation

copy

Full Screen

1import {ngModule2} from 'ng-mocks';2describe('ngModule2', () => {3 it('is a function', () => {4 expect(ngModule2).toEqual(jasmine.any(Function));5 });6});7import {ngMocksGlobal} from 'ng-mocks';8describe('ngMocksGlobal', () => {9 it('is a function', () => {10 expect(ngMocksGlobal).toEqual(jasmine.any(Function));11 });12});13import {ngMocksGuts} from 'ng-mocks';14describe('ngMocksGuts', () => {15 it('is a function', () => {16 expect(ngMocksGuts).toEqual(jasmine.any(Function));17 });18});19import {ngMocksInstance} from 'ng-mocks';20describe('ngMocksInstance', () => {21 it('is a function', () => {22 expect(ngMocksInstance).toEqual(jasmine.any(Function));23 });24});25import {ngMocksKeep} from 'ng-mocks';26describe('ngMocksKeep', () => {27 it('is a function', () => {28 expect(ngMocksKeep).toEqual(jasmine.any(Function));29 });30});31import {ngMocksMock} from 'ng-mocks';32describe('ngMocksMock', () => {33 it('is a function', () => {34 expect(ngMocksMock).toEqual(jasmine.any(Function));35 });36});37import {ngMocksUniverse} from 'ng-mocks';38describe('ngMocksUniverse', () => {39 it('is a function', () => {40 expect(ngMocksUniverse).toEqual(jasmine.any(Function));41 });42});43import {ngMocksUniverse} from 'ng-mocks';44describe('ngMocksUniverse', () => {45 it('is a

Full Screen

Using AI Code Generation

copy

Full Screen

1import {ngModule2} from 'ng-mocks';2import {MyModule} from './my-module';3import {MyService} from './my-service';4describe('test', () => {5 it('should test', () => {6 ngModule2(MyModule, {7 {provide: MyService, useValue: {myMethod: () => 'myValue'}},8 });9 });10});11The ngModule2 method of ng-mocks is a wrapper around the TestBed.configureTestingModule method. It is used to configure the module under test. The ngModule2 method takes two arguments. The first argument is the module under test. The second argument is an object that contains the configuration information for the module under test. The second argument to ngModule2 is an object with the following properties: providers: An array of providers that will be used to configure the module under test. The providers array contains objects that have the following properties: provide: The dependency to be provided. This is typically a class or a string. useValue: The value to use for the dependency. This can be any value. The ngModule2 method returns a TestModuleMeta object. This object can be used to configure the module under test. This object contains the following properties: declarations: An array of component and directive declarations for the module under test. imports: An

Full Screen

Using AI Code Generation

copy

Full Screen

1import { ngModule2 } from 'ng-mocks';2describe('MyComponent', () => {3 ngModule2({4 imports: [MyModule],5 });6 it('should create', () => {7 const fixture = TestBed.createComponent(MyComponent);8 const component = fixture.componentInstance;9 expect(component).toBeTruthy();10 });11});12import ngMocks from 'ng-mocks';13describe('MyComponent', () => {14 ngMocks.defaultMock(MyModule, {15 });16 it('should create', () => {17 const fixture = TestBed.createComponent(MyComponent);18 const component = fixture.componentInstance;19 expect(component).toBeTruthy();20 });21});22import { ngMocks } from 'ng-mocks';23describe('MyComponent', () => {24 ngMocks.defaultMock(MyModule, {25 });26 it('should create', () => {27 const fixture = TestBed.createComponent(MyComponent);28 const component = fixture.componentInstance;29 expect(component).toBeTruthy();30 });31});32import ngMocks from 'ng-mocks';33describe('MyComponent', () => {34 ngMocks.defaultMock(MyModule, {35 });36 it('should create', () => {37 const fixture = TestBed.createComponent(MyComponent);38 const component = fixture.componentInstance;39 expect(component).toBeTruthy();40 });41});42import { ngMocks } from 'ng-mocks';43describe('MyComponent', () => {44 ngMocks.defaultMock(MyModule, {45 });46 it('should create', () => {47 const fixture = TestBed.createComponent(MyComponent);48 const component = fixture.componentInstance;49 expect(component).toBeTruthy();50 });51});52import ngMocks from 'ng-mocks';53describe('MyComponent', () => {54 ngMocks.defaultMock(MyModule, {55 });56 it('should create', () => {

Full Screen

Using AI Code Generation

copy

Full Screen

1import {ngModule2} from 'ng-mocks';2import {MyModule} from './my.module';3import {MyService} from './my.service';4describe('TestModule', () => {5 beforeEach(() => {6 ngModule2(MyModule);7 });8 it('should create', () => {9 const service: MyService = TestBed.get(MyService);10 expect(service).toBeTruthy();11 });12});13"paths": {14}15 at Object.ngModule2 (C:\Users\user\source\repos\MyApp\MyApp\node_modules\ng-mocks\dist\ng-mocks.js:1:18483)16 at Object.<anonymous> (C:\Users\user\source\repos\MyApp\MyApp\src\app\app.component.spec.ts:7:1)17import { ComponentFixture, TestBed } from '@angular/core/testing';18import { ngModule2 } from 'ng-mocks';19import { AppComponent } from './app.component';20import { MyService } from './my.service';21describe('AppComponent', () => {22 let component: AppComponent;23 let fixture: ComponentFixture<AppComponent>;24 beforeEach(async () => {25 await TestBed.configureTestingModule({26 imports: [27 ngModule2(MyService)28 }).compileComponents();29 });30 beforeEach(() => {31 fixture = TestBed.createComponent(AppComponent);32 component = fixture.componentInstance;33 fixture.detectChanges();34 });35 it('should create', () => {

Full Screen

Using AI Code Generation

copy

Full Screen

1import { ngModule2 } from 'ng-mocks';2import { AppModule } from './app.module';3import { MockModule } from 'ng-mocks';4import { ExternalModule } from './external.module';5import { MockComponent } from 'ng-mocks';6import { ExternalComponent } from './external.component';7describe('AppComponent', () => {8 beforeEach(() => {9 TestBed.configureTestingModule({10 imports: [11 ngModule2(AppModule),12 MockModule(ExternalModule),13 MockComponent(ExternalComponent),14 });15 });16 it('should create the app', () => {17 const fixture = TestBed.createComponent(AppComponent);18 const app = fixture.debugElement.componentInstance;19 expect(app).toBeTruthy();20 });21});22import { NgModule } from '@angular/core';23import { BrowserModule } from '@angular/platform-browser';24import { AppComponent } from './app.component';25import { ExternalModule } from './external.module';26@NgModule({27 imports: [28})29export class AppModule { }30import { NgModule } from '@angular/core';31import { ExternalComponent } from './external.component';32@NgModule({33 imports: [],34})35export class ExternalModule { }36import { Component } from '@angular/core';37@Component({38})39export class ExternalComponent { }40import { async, ComponentFixture, TestBed } from '@angular/core/testing';41import { ExternalComponent } from './external.component';42import { MockComponent } from 'ng-mocks';43describe('ExternalComponent', () => {44 let component: ExternalComponent;45 let fixture: ComponentFixture<ExternalComponent>;46 beforeEach(async(() => {47 TestBed.configureTestingModule({48 MockComponent(ExternalComponent),49 })50 .compileComponents();51 }));52 beforeEach(() => {53 fixture = TestBed.createComponent(ExternalComponent);54 component = fixture.componentInstance;55 fixture.detectChanges();56 });57 it('should create', () => {58 expect(component).toBeTruthy();

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ng-mocks automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful