Advertisement
Guest User

Untitled

a guest
Aug 21st, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { async, TestBed } from '@angular/core/testing';
  2. import { MatListModule, MatSidenavModule } from '@angular/material';
  3. import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
  4. import { RouterTestingModule } from '@angular/router/testing';
  5. import { ApolloModule } from 'apollo-angular';
  6. import { ApolloTestingModule } from 'apollo-angular/testing';
  7. import { ApolloClient, ApolloClientOptions } from 'apollo-client';
  8. import { AppComponent } from './app.component';
  9.  
  10. // Copy a GQL response (that includes __typename etc)
  11. const gqlResponse = `
  12.   {
  13.     "data": {
  14.       "comments": []
  15.     }
  16.   }`;
  17.  
  18. function provideClient(): any {
  19.   return new ApolloClient({
  20.     networkInterface: {
  21.       query: function () {
  22.         return new Promise(resolve => resolve(gqlResponse));
  23.       }
  24.     }
  25.   });
  26. }
  27.  
  28. describe('AppComponent', () => {
  29.   beforeEach(async(() => {
  30.     TestBed.configureTestingModule({
  31.       declarations: [AppComponent],
  32.       imports: [
  33.         ApolloTestingModule,
  34.         MatListModule,
  35.         MatSidenavModule,
  36.         RouterTestingModule,
  37.         BrowserAnimationsModule,
  38.         ApolloModule.withClient(provideClient)
  39.         // Failed: apollo_angular_1.ApolloModule.withClient is not a function
  40.       ]
  41.     }).compileComponents();
  42.   }));
  43.  
  44.   it('should make a srv req', async(() => {
  45.  
  46.    
  47.   }));
  48.  
  49.   it('should create the app', async(() => {
  50.     const fixture = TestBed.createComponent(AppComponent);
  51.     const app = fixture.debugElement.componentInstance;
  52.     expect(app).toBeTruthy();
  53.   }));
  54. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement