Guest User

Untitled

a guest
Sep 14th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { async, ComponentFixture, TestBed } from '@angular/core/testing';
  2. import { NO_ERRORS_SCHEMA } from '@angular/core';
  3. import {FormsModule, ReactiveFormsModule} from '@angular/forms';
  4. import { MatSnackBarModule, MatInputModule } from '@angular/material';
  5. import {
  6.     MatFormFieldModule,
  7.     MatSelectModule,
  8.     MatIconModule,
  9.     MatAutocompleteModule,
  10.     MatChipsModule,
  11.     MatListModule
  12. } from '@angular/material';
  13. import {CommonModule} from '@angular/common';
  14. import { MailingTargetService } from '../services/mailing-target.service';
  15. import { PersonService } from '../services/person.service';
  16. import { DialogService } from '../services/dialog.service';
  17.  
  18. import { MailingTargetComponent } from './mailing-target.component';
  19. import { PersonComponent } from './person/person.component';
  20. import {RouterTestingModule} from "@angular/router/testing";
  21. import {BrowserAnimationsModule} from "@angular/platform-browser/animations";
  22. import {BehaviorSubject} from "rxjs/BehaviorSubject";
  23.  
  24. describe('MailingTargetComponent', () => {
  25.     let component: MailingTargetComponent;
  26.     let fixture: ComponentFixture<MailingTargetComponent>;
  27.     const fakeService = {};
  28.  
  29.     const mailTargetFakeService = {
  30.         getTargetData$: new BehaviorSubject<any>(null),
  31.         getTargetDetails() {
  32.             this.getBasicSetupData$.next([{
  33.                 uuid: 'a60a7a3b-9ca6-4785-92cf-778b17324682',
  34.                 contacts: [
  35.                     {
  36.                         uuid: 'f92edf71-6c98-4057-8578-d958ec1f7424',
  37.                         firstname: "John",
  38.                         lastname: "Doe",
  39.                         email: "jdoe@eqs.com"
  40.                     },
  41.                     {
  42.                         uuid: '7a690a97-9598-4c79-89c7-091e688e490a',
  43.                         firstname: "Josh",
  44.                         lastname: "L",
  45.                         email: "qweqwe@asd.com"
  46.                     },
  47.                 ],
  48.                 lists: [
  49.                     {
  50.                         uuid: "6a690a97-9598-4c79-89c7-091e688e490d",
  51.                         title: "All Developers in Germany",
  52.                         number_of_contacts_with_email: 5,
  53.                         selected: true
  54.                     },
  55.                     {
  56.                         uuid: "a50a7a3b-9ca6-4785-92cf-778b17324685",
  57.                         title: "All Developers in India",
  58.                         number_of_contacts_with_email: 3,
  59.                         selected: false
  60.                     },
  61.                     {
  62.                         uuid: "3666d5e4-a85a-47ad-9d7b-48e57ac64006",
  63.                         title: "HR in India",
  64.                         number_of_contacts_with_email: 3,
  65.                         selected: false
  66.                     }
  67.                 ]
  68.             }]);
  69.         },
  70.         getAvailableList() {
  71.             this.getTargetData$.next([{
  72.                 uuid: 'a60a7a3b-9ca6-4785-92cf-778b17324682',
  73.                 contacts: [
  74.                     {
  75.                         uuid: 'f92edf71-6c98-4057-8578-d958ec1f7424',
  76.                         firstname: "John",
  77.                         lastname: "Doe",
  78.                         email: "jdoe@eqs.com"
  79.                     },
  80.                     {
  81.                         uuid: '7a690a97-9598-4c79-89c7-091e688e490a',
  82.                         firstname: "Josh",
  83.                         lastname: "L",
  84.                         email: "qweqwe@asd.com"
  85.                     },
  86.                 ],
  87.                 lists: [
  88.                     {
  89.                         uuid: "6a690a97-9598-4c79-89c7-091e688e490d",
  90.                         title: "All Developers in Germany",
  91.                         number_of_contacts_with_email: 5,
  92.                         selected: true
  93.                     },
  94.                     {
  95.                         uuid: "a50a7a3b-9ca6-4785-92cf-778b17324685",
  96.                         title: "All Developers in India",
  97.                         number_of_contacts_with_email: 3,
  98.                         selected: false
  99.                     },
  100.                     {
  101.                         uuid: "3666d5e4-a85a-47ad-9d7b-48e57ac64006",
  102.                         title: "HR in India",
  103.                         number_of_contacts_with_email: 3,
  104.                         selected: false
  105.                     }
  106.                 ]
  107.             }]);
  108.         }
  109.     };
  110.     const personFakeService = {
  111.         getUserData$: new BehaviorSubject<any>(null),
  112.         getUserList() {
  113.             this.getUserData$.next([{
  114.                 uuid: 'a60a7a3b-9ca6-4785-92cf-778b17324682',
  115.                 contacts: [
  116.                     {
  117.                         uuid: 'f92edf71-6c98-4057-8578-d958ec1f7424',
  118.                         firstname: "John",
  119.                         lastname: "Doe",
  120.                         email: "jdoe@eqs.com"
  121.                     },
  122.                     {
  123.                         uuid: '7a690a97-9598-4c79-89c7-091e688e490a',
  124.                         firstname: "Josh",
  125.                         lastname: "L",
  126.                         email: "qweqwe@asd.com"
  127.                     },
  128.                 ],
  129.                 lists: [
  130.                     {
  131.                         uuid: "6a690a97-9598-4c79-89c7-091e688e490d",
  132.                         title: "All Developers in Germany",
  133.                         number_of_contacts_with_email: 5,
  134.                         selected: true
  135.                     },
  136.                     {
  137.                         uuid: "a50a7a3b-9ca6-4785-92cf-778b17324685",
  138.                         title: "All Developers in India",
  139.                         number_of_contacts_with_email: 3,
  140.                         selected: false
  141.                     },
  142.                     {
  143.                         uuid: "3666d5e4-a85a-47ad-9d7b-48e57ac64006",
  144.                         title: "HR in India",
  145.                         number_of_contacts_with_email: 3,
  146.                         selected: false
  147.                     }
  148.                 ]
  149.             }]);
  150.         }
  151.     };
  152.  
  153.  
  154.  
  155.     beforeEach(async(() => {
  156.         TestBed.configureTestingModule({
  157.             imports: [
  158.                 CommonModule,
  159.                 FormsModule,
  160.                 ReactiveFormsModule,
  161.                 MatSnackBarModule,
  162.                 MatInputModule,
  163.                 MatFormFieldModule,
  164.                 MatSelectModule,
  165.                 MatIconModule,
  166.                 MatAutocompleteModule,
  167.                 MatChipsModule,
  168.                 MatListModule,
  169.                 BrowserAnimationsModule,
  170.                 RouterTestingModule
  171.             ],
  172.             declarations: [ MailingTargetComponent, PersonComponent ],
  173.             providers: [
  174.                 {provide: MailingTargetService, useValue: mailTargetFakeService},
  175.                 {provide: PersonService, useValue: personFakeService},
  176.                 {provide: DialogService, useValue: fakeService}
  177.             ],
  178.             schemas: [ NO_ERRORS_SCHEMA ]
  179.         })
  180.             .compileComponents();
  181.     }));
  182.  
  183.     beforeEach(() => {
  184.         fixture = TestBed.createComponent(MailingTargetComponent);
  185.         component = fixture.componentInstance;
  186.         fixture.detectChanges();
  187.     });
  188.  
  189.     it('should create', () => {
  190.         expect(component).toBeTruthy();
  191.     });
  192. });
Add Comment
Please, Sign In to add comment