beforeEach(() => {
     injector = ReflectiveInjector.resolveAndCreate([
         AlfrescoSettingsService,
         AlfrescoApiService,
         AlfrescoAuthenticationService,
         UploadService
     ]);
 });
Example #2
0
export function serverBootstrap(
    appComponentType: Type,
    customProviders?: Array<any /*Type | Provider | any[]*/>): Promise<ComponentRef<any>> {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  let providers = [SERVER_APPLICATION_PROVIDERS, customProviders || []];
  var appInjector = ReflectiveInjector.resolveAndCreate(providers, serverPlatform().injector);
  return coreLoadAndBootstrap(appComponentType, appInjector);
}
Example #3
0
 function makeLocation(
     baseHref: string = '/my/app', provider: any = /*@ts2dart_const*/[]): Location {
   locationStrategy = new MockLocationStrategy();
   locationStrategy.internalBaseHref = baseHref;
   let injector = ReflectiveInjector.resolveAndCreate(
       [Location, {provide: LocationStrategy, useValue: locationStrategy}, provider]);
   return location = injector.get(Location);
 }
export function GET_HTTP_PROVIDERS_INJECTOR(additionalProviders?: any[]): ReflectiveInjector {
  
  if (additionalProviders) {
    providers = providers.concat(additionalProviders);
  }  

  return ReflectiveInjector.resolveAndCreate(providers);  
}
 beforeEach(function() {
   const injector = ReflectiveInjector.resolveAndCreate([
     MATCH_ROUTE_PROVIDERS,
     RESOURCE_LOADER_PROVIDERS,
     provide(ROUTES, { useValue: routes })
   ]);
   traverser = injector.get(RouteTraverser);
 });
Example #6
0
export function bootstrapApp(
    appComponentType: Type,
    customProviders?: Array<any /*Type | Provider | any[]*/>): Promise<ComponentRef<any>> {
  var appInjector = ReflectiveInjector.resolveAndCreate(
      [WORKER_APP_DYNAMIC_APPLICATION_PROVIDERS, isPresent(customProviders) ? customProviders : []],
      workerAppPlatform().injector);
  return coreLoadAndBootstrap(appInjector, appComponentType);
}
Example #7
0
export function bootstrap(
    appComponentType: Type,
    customProviders?: Array<any /*Type | Provider | any[]*/>): Promise<ComponentRef<any>> {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  var appInjector = ReflectiveInjector.resolveAndCreate(
      [BROWSER_APP_PROVIDERS, isPresent(customProviders) ? customProviders : []],
      browserPlatform().injector);
  return coreLoadAndBootstrap(appInjector, appComponentType);
}
Example #8
0
    beforeEach(() => {

      injector = ReflectiveInjector.resolveAndCreate([
        StoreModule.provideStore({ todos, todoCount }).providers
      ]);

      store = injector.get(Store);
      dispatcher = injector.get(Dispatcher);
    });
    /**
     * Gets Angular2Apollo service and calls a method
     *
     * Checks if method with the same name has been called
     * with the same same options
     *
     * It also checks if service method returns result of ApolloClient method
     *
     * @param  {string} method  Name of method you want to test
     * @param  {any} options    Used options
     * @param  {any} result     Mock result
     */
    function rawApiCall(method: string, options = 'options', result = 'result') {
      spyOn(client, method).and.returnValue(result);

      const injector = ReflectiveInjector.resolveAndCreate([defaultApolloClient(client), APOLLO_PROVIDERS]);
      const service = injector.get(Angular2Apollo);

      expect(service[method](options)).toBe(result);
      expect(client[method]).toHaveBeenCalledWith(options);
    }
    it('should work mockWrapper with fakeDI', () => {
        let injector = ReflectiveInjector.resolveAndCreate([
            MockWrapperService,
            provide(TestService, { useClass: MockTestService })]);

        let service = injector.get(MockWrapperService);
        expect(service.getService()).toContain({ fname: 'vasya', lname: 'pupkin' });

    });
 beforeEach(() => {
     injector = ReflectiveInjector.resolveAndCreate([
         WidgetVisibilityService,
         AlfrescoSettingsService,
         AlfrescoApiService,
         AlfrescoAuthenticationService,
         StorageService
     ]);
 });
Example #12
0
 it('works', () => {
   // #docregion Injector
   const injector: Injector =
       ReflectiveInjector.resolveAndCreate([{provide: 'validToken', useValue: 'Value'}]);
   expect(injector.get('validToken')).toEqual('Value');
   expect(() => injector.get('invalidToken')).toThrowError();
   expect(injector.get('invalidToken', 'notFound')).toEqual('notFound');
   // #enddocregion
 });
Example #13
0
  constructor(http: Http, appSettings: AppSettingsService, notifierService: NotifierService, logger: LoggerService ) {
    super(http, appSettings, notifierService, logger);

    // Inject service for test data
    const injector = ReflectiveInjector.resolveAndCreate([TestDataService]);
    const testDataService = injector.get(TestDataService);

    this.testDataService = testDataService;
  }
 it('should provide a FirebaseRef for the FIREBASE_REF binding', () => {
   var injector = ReflectiveInjector.resolveAndCreate([
     provide(FirebaseUrl, {
       useValue: localServerUrl
     }),
     FIREBASE_PROVIDERS
   ]);
   expect(typeof injector.get(FirebaseRef).on).toBe('function');
 })
Example #15
0
  beforeEach(function() {
    const injector = ReflectiveInjector.resolveAndCreate([
      provideStore(reducer),
      Actions
    ]);

    actions$ = injector.get(Actions);
    dispatcher = injector.get(Dispatcher);
  });
Example #16
0
export function serverBootstrap(
    appComponentType: Type,
    providers: Array<any /*Type | Provider | any[]*/>): Promise<ComponentRef<any>> {
  console.warn(
      'serverBootstrap is deprecated. Create an @AppModule and use `bootstrapModule` with the `serverDynamicPlatform()` instead.');
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  var appInjector = ReflectiveInjector.resolveAndCreate(providers, serverPlatform().injector);
  return coreLoadAndBootstrap(appComponentType, appInjector);
}
Example #17
0
  beforeEach(function() {
    const injector = ReflectiveInjector.resolveAndCreate([
      StoreModule.forRoot(reducer).providers || [],
      Actions,
    ]);

    actions$ = injector.get(Actions);
    dispatcher = injector.get(ScannedActionsSubject);
  });
Example #18
0
  beforeEach(() => {
    injector = ReflectiveInjector.resolveAndCreate([
      { provide: DOCUMENT, useValue: { body: {} } },
      { provide: ScrollService, useValue: { topOffset: 50 } },
      ScrollSpyService
    ]);

    scrollSpyService = injector.get(ScrollSpyService);
  });
 beforeEach(() => {
   injector = ReflectiveInjector.resolveAndCreate([
       NavigationService,
       { provide: LocationService, useFactory: () => new MockLocationService('a') },
       { provide: ConnectionBackend, useClass: MockBackend },
       { provide: RequestOptions, useClass: BaseRequestOptions },
       Http
   ]);
 });
Example #20
0
  function runSaga(saga: Provider): Store<number> {
    const injector = ReflectiveInjector.resolveAndCreate([
      provideStore(reducer, 0),
      installSagaMiddleware(saga),
      schedulerProvider
    ]);

    return injector.get(Store);
  }
 beforeEach(() => {
     injector = ReflectiveInjector.resolveAndCreate([
         ActivitiTaskListService,
         AlfrescoSettingsService,
         AlfrescoApiService,
         AlfrescoAuthenticationService,
         StorageService
     ]);
 });
Example #22
0
  beforeEach(function() {
    const injector = ReflectiveInjector.resolveAndCreate([
      provideStore(reducer),
      STATE_UPDATES_PROVIDER
    ]);

    stateUpdates$ = injector.get(StateUpdates);
    dispatcher = injector.get(Dispatcher);
  });
 t.be(() => {
   let injector = ReflectiveInjector.resolveAndCreate([
     TEST_ROUTER_PROVIDERS(),
     Angulartics2, Angulartics2Segment, AnalyticsService
   ]);
   analyticsService = injector.get(AnalyticsService);
   analytics = new TestAnalytics(analyticsService);
   analytics.category = 'TEST';
 });
 t.be(() => {
   let injector = ReflectiveInjector.resolveAndCreate([
     TEST_ROUTER_PROVIDERS(),
     Angulartics2, Angulartics2Segment, AnalyticsService
   ]);
   analyticsService = injector.get(AnalyticsService);
   analyticsService.devMode(false);
   segment = injector.get(Angulartics2Segment);
 });
Example #25
0
 beforeEach(() => {
     const injector = ReflectiveInjector.resolveAndCreate([
         {provide: ConnectionBackend, useClass: MockBackend},
         {provide: RequestOptions, useClass: BaseRequestOptions},
         Http, MovieService
     ]);
     http = injector.get(Http);
     movieService = injector.get(MovieService);
 });
export function customBootstrap(appComponentType: any, customProviders: Provider[] = null): Promise<ComponentRef<any>> {

  CustomDomAdapter.makeCurrent();

  let logger = {
    logGroup: () => {
      console.log('---');
    },
    logError: (error: Error) => {
      console.error(error);
    },
    logGroupEnd: () => {
      console.log('---');
    }
  };
  let platformProviders = [
    PLATFORM_COMMON_PROVIDERS,
    provide(XHR, { useClass: XHRShim }),
    provide(ExceptionHandler, { useFactory: () => new ExceptionHandler(logger, true), deps: [] })
  ];

  let appProviders = [
    APPLICATION_COMMON_PROVIDERS,
    COMPILER_PROVIDERS,
    SanitizationService,
    CustomRootRenderer,
    provide(RootRenderer, { useClass: CustomRootRenderer }),
    CustomRenderer,
    provide(Renderer, { useClass: CustomRenderer })
  ];
  if (customProviders) {
    appProviders.push(customProviders);
  }

  let platform = getPlatform();
  if (!isPresent(platform)) {
    platform = createPlatform(ReflectiveInjector.resolveAndCreate(platformProviders));
  }


  reflector.reflectionCapabilities = new ReflectionCapabilities();
  let appInjector = ReflectiveInjector.resolveAndCreate(appProviders, platform.injector);
  return coreLoadAndBootstrap(appInjector, appComponentType);
}
Example #27
0
    beforeEach(function () {
        const injector = ReflectiveInjector.resolveAndCreate([
            ShopEffects,
            MOCK_EFFECTS_PROVIDERS,
            // Mock out other dependencies (like Http) here
        ]);

        shop = injector.get(ShopEffects);
        updates$ = injector.get(MockStateUpdates);
    });
Example #28
0
  beforeEach(function() {
    routeSet$ = new Subject<Match>();
    spyOn(router, 'replace');
    spyOn(observer, 'next');
    const injector = ReflectiveInjector.resolveAndCreate([
      provide(Router, { useValue: router })
    ]);

    redirect = injector.resolveAndInstantiate(RedirectHook);
  });
 beforeEach(() => {
     injector = ReflectiveInjector.resolveAndCreate([
         AlfrescoSettingsService,
         AlfrescoApiService,
         AlfrescoAuthenticationService,
         AlfrescoContentService,
         EcmUserService,
         StorageService
     ]);
 });
Example #30
0
export function browserTestCompiler(
    {providers = [], useJit = true}: {providers?: Array<Type|Provider|any[]>,
                                      useJit?: boolean} = {}): Compiler {
  const injector = ReflectiveInjector.resolveAndCreate([
    TEST_BROWSER_DYNAMIC_COMPILER_PROVIDERS,
    {provide: CompilerConfig, useValue: new CompilerConfig({genDebugInfo: true, useJit: useJit})},
    providers ? providers : []
  ]);
  return injector.get(Compiler);
}