Ejemplo n.º 1
0
  it(`supports font-awesome imports`, (done) => {
    host.writeMultipleFiles({
      'src/styles.scss': `
        $fa-font-path: "~font-awesome/fonts";
        @import "~font-awesome/scss/font-awesome";
      `,
    });

    const overrides = { extractCss: true, styles: [`src/styles.scss`] };

    runTargetSpec(host, browserTargetSpec, overrides).pipe(
      tap((buildEvent) => expect(buildEvent.success).toBe(true)),
    ).toPromise().then(done, done.fail);
  }, 30000);
Ejemplo n.º 2
0
  canActivate(
    next: ActivatedRouteSnapshot,
    state: RouterStateSnapshot): Observable<boolean> {

    return this.auth.user$.pipe(
      take(1),
      map(user => ((!user && this.auth.canEdit(user)))),
      tap((canEdit: boolean) => {
        if (!canEdit) {
          console.error('Access denied. Must have permission to EDIT content');
        }
      })
    );
  }
 intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
   return next.handle(request).pipe(
     tap(
       (event: HttpEvent<any>) => {},
       (err: any) => {
         if (err instanceof HttpErrorResponse) {
           if (!(err.status === 401 && (err.message === '' || (err.url && err.url.includes('/api/account'))))) {
             this.eventManager.broadcast({ name: 'bestMealApp.httpError', content: err });
           }
         }
       }
     )
   );
 }
Ejemplo n.º 4
0
 ngxsBootstrap<T>(action: T, results: StatesAndDefaults | undefined): void {
   this.internalStateOperations
     .getRootStateOperations()
     .dispatch(action)
     .pipe(
       filter(() => !!results),
       tap(() => this.invokeInit(results!.states)),
       mergeMap(() => this.bootstrapper.appBootstrapped$),
       filter(appBootstrapped => !!appBootstrapped)
     )
     .subscribe(() => {
       this.invokeBootstrap(results!.states);
     });
 }
Ejemplo n.º 5
0
 observe(() => {
   const {
     job: { id }
   } = createUpdateWithSchedule;
   return updateJob(id, createUpdateWithSchedule).pipe(
     tap(() =>
       expect(mockRequest).toHaveBeenLastCalledWith(expect.anything(), {
         body: JSON.stringify(createUpdateWithSchedule.schedule),
         method: "PUT",
         headers: expect.anything()
       })
     )
   );
 })
 checkStore(): Observable<boolean> {
   return this.store.select(fromStore.getPizzasLoaded)
     .pipe(
       tap((loaded) => {
         if (!loaded) {
           this.store.dispatch(new fromStore.LoadPizzas());
         }
       }),
       filter((loaded) => {
         return loaded;
       }),
       take(1)
     )
 }
  it('preserves script order', (done) => {
    host.writeMultipleFiles(scripts);

    const overrides = { scripts: getScriptsOption() };

    runTargetSpec(host, browserTargetSpec, overrides).pipe(
      tap((buildEvent) => expect(buildEvent.success).toBe(true)),
      tap(() => {
        const re = new RegExp(
          /.*['"]input-script['"](.|\n|\r)*/.source
          + /['"]zinput-script['"](.|\n|\r)*/.source
          + /['"]finput-script['"](.|\n|\r)*/.source
          + /['"]uinput-script['"](.|\n|\r)*/.source
          + /['"]binput-script['"](.|\n|\r)*/.source
          + /['"]ainput-script['"](.|\n|\r)*/.source
          + /['"]cinput-script['"]/.source,
        );
        const fileName = './dist/scripts.js';
        const content = virtualFs.fileBufferToString(host.scopedSync().read(normalize(fileName)));
        expect(content).toMatch(re);
      }),
    ).toPromise().then(done, done.fail);
  }, Timeout.Basic);
Ejemplo n.º 8
0
  it('runs watch mode', (done) => {
    const overrides = { watch: true };

    runTargetSpec(host, { project: 'app', target: 'server' }, overrides).pipe(
      tap((buildEvent) => {
        expect(buildEvent.success).toBe(true);

        const fileName = join(outputPath, 'main.js');
        const content = virtualFs.fileBufferToString(host.scopedSync().read(normalize(fileName)));
        expect(content).toMatch(/AppServerModuleNgFactory/);
      }),
      take(1),
    ).subscribe(undefined, done.fail, done);
  });
Ejemplo n.º 9
0
  it('supports sourcemaps', (done) => {
    const overrides = { sourceMap: true };

    runTargetSpec(host, { project: 'app', target: 'server' }, overrides).pipe(
      tap((buildEvent) => {
        expect(buildEvent.success).toBe(true);

        const fileName = join(outputPath, 'main.js');
        const content = virtualFs.fileBufferToString(host.scopedSync().read(normalize(fileName)));
        expect(content).toMatch(/AppServerModuleNgFactory/);
        expect(host.scopedSync().exists(join(outputPath, 'main.js.map'))).toBeTruthy();
      }),
    ).toPromise().then(done, done.fail);
  });
Ejemplo n.º 10
0
 canActivate(
   next: ActivatedRouteSnapshot,
   state: RouterStateSnapshot
 ): Observable<boolean> {
   return this.store.select(s => s.environement).pipe(
     map(env => env.uid),
     map(uid => !!uid),
     tap(hasUid => {
       if (!hasUid) {
         this.router.navigate(['/main/caption']);
       }
     })
   );
 }