Example #1
0
 constructor(private store$: Store<AppState>) {
   this.counter$ = store$.select('counter');
 }
 ngOnInit() {
   this.shoppingListState = this.store.select('shoppingList');
 }
 this.usersService.getUsers().subscribe(users => {
     this.users = users;
     this.store.dispatch({type: INIT_USERS, payload: this.users});
 });
 ngOnInit() {
   this.isFetching$ = this.store.select(fromCustomer.getCustomersLoading);
   this.customers$ = this.store.select(fromCustomer.getCustomers);
   this.store.dispatch(new customerActions.LoadAction());
 }
Example #5
0
 clearFlashMessage() {
   this.store.dispatch(new ClearFlashMessage())
 }
   toggle(node: TreeNode){
     this._store.dispatch({type: TOGGLE_NODE, payload: node.name});
 }
 constructor(private store: Store<any>) {
   this.names = store.select('names');
 }  
 hasHotelInStore(id: number){
   return this.store.let(hasHotel(id)).take(1);
 }
 .do(action => this.store.dispatch(action))
describe('EpisodesComponent', () => {
	let component: EpisodesComponent;
	let fixture: ComponentFixture<EpisodesComponent>;
	let el: DebugElement;
  let store: Store<PodcastState>;
	let datePipe: DatePipe;

	beforeEach(
		async(() => {
			TestBed.configureTestingModule({
				declarations: [EpisodesComponent],
				imports: [
					MatListModule,
          MatPaginatorModule,
          RouterTestingModule.withRoutes([]),

					StoreModule.forRoot({}),
					StoreModule.forFeature('podcast', fromPodcast.reducer),

					RouterTestingModule
				],
			}).compileComponents();

			datePipe = new DatePipe('en-US');
		})
	);

  beforeEach(async () => {
    store = TestBed.get(Store);
    spyOn(store, 'dispatch').and.callThrough();
  });

	beforeEach(async () => {
	  store.dispatch(new FindItemsByPodcastsAndPageSuccessAction(items));
		fixture = TestBed.createComponent(EpisodesComponent);
		component = fixture.componentInstance;
		fixture.detectChanges();
		el = fixture.debugElement;
		await fixture.whenStable();
	});

	it('should create', () => {
	  /* Given */
    /* When */
    /* Then */
		expect(component).toBeTruthy();
	});

	it('should have coherent number of items', () => {
		/* Given */
		/* When  */
		const itemsElement = el.queryAll(By.css('[mat-list-item]'));
		/* Then  */
		expect(itemsElement.length).toEqual(10);
	});

	it('should have each line with cover', () => {
		/* Given */
		const coversExpected = items.content.map(v => v.cover.url);
		/* When  */
		const coversUrl = el.queryAll(By.css('img')).map(v => v.properties.src);
		/* Then  */
		expect(coversExpected).toEqual(coversUrl);
	});

	it('should have each line with title', () => {
		/* Given */
		const titleExpected = items.content.map(v => v.title);
		/* When  */
		const titles = el.queryAll(By.css('h3[matLine]')).map(asText);
		/* Then  */
		expect(titleExpected).toEqual(titles);
	});

	it('should have each line with date', () => {
		/* Given */
		const dateExpected = items.content.map(v => v.pubDate).map(v => datePipe.transform(v, 'dd/MM/yyyy à HH:mm'));
		/* When  */
		const dates = el.queryAll(By.css('p[matLine]')).map(asText);
		/* Then  */
		expect(dateExpected).toEqual(dates);
	});

	function asText(v: DebugElement) {
		return v.nativeElement.textContent.trim();
	}
});
 waitForHotelsToLoad() {
   return this.store.let(getHotelsLoaded())
     .filter(loaded => loaded)
     .take(1);
 }
Example #12
0
 reset() {
   this.store$.dispatch({ type: RESET });
 }
Example #13
0
 decrement() {
   this.store$.dispatch({ type: DECREMENT });
 }
Example #14
0
 increment() {
   this.store$.dispatch({ type: INCREMENT });
 }
Example #15
0
 constructor(private http: Http, private _store: Store<any>) {
   this.token$ = _store.select<Auth>('auth')
                       .map(data => data['token'])
                       .filter(token => !!token);
 }
Example #16
0
 goBack() {
   this.store.dispatch(new fromStore.Back);
 }
 constructor(
   private _store : Store<AppState>
 ){
   this.nodes = this._store.select<TreeNode[]>('tree');
 } 
Example #18
0
 addAlert(message) {
   this.store.dispatch({type: ADD_ALERT_NOTIFICATION, payload: message});
 }
    logout() {

      this.store.dispatch(new Logout());

    }
Example #20
0
 addError(message) {
   this.store.dispatch({type: ADD_ERROR_NOTIFICATION, payload: message});
 }
 add(name: string): void {
   this.store.dispatch({ type: NAME_LIST_ACTIONS.NAME_ADDED, payload: name });
 }
Example #22
0
 clearNotification(id: string) {
   this.store.dispatch({type: CLEAR_NOTIFICATION, payload: id});
 }
 delete(customer: Customer) {
   this.store.dispatch(new customerActions.DeleteAction(customer));
 }
 ngOnInit() {
   this.store.dispatch(new GetPaymentProvidersAction());
   this.paymentProviders$ = this.store.select(getBackendPaymentProviders);
   this.status$ = this.store.select(getBackendPaymentProvidersStatus);
 }
Example #25
0
 tap(loaded => {
   if (!loaded) {
     this.store.dispatch(new fromStore.LoadVideos());
   }
 }),
 this.dialogService.openConfirm(config).afterClosed().subscribe((confirmed: boolean) => {
   if (confirmed) {
     this.store.dispatch(new RemovePaymentProviderAction((paymentProvider)));
   }
 });
 onEditItem(index: number) {
   this.store.dispatch(new ShoppingListActions.StartEdit(index));
 }
Example #28
0
 changeMember(){
   this.store.dispatch({type:'UPDATE_MEMBER',payload:{member:'Father'}});
 }
 onClick() {
   this.store.dispatch(new dashboardActions.LoadDashboardsAction('123'));
 }
Example #30
0
 logout() {
   this.closeSidenav();
   this.store.dispatch(new AuthActions.LogoutConfirmation());
 }