Tutorial by Examples

class ObserverMock implements Observer<any> { closed?: boolean = false; // inherited from Observer nextVal: any = ''; // variable I made up constructor() {} next = (value: any): void => { this.nextVal = value; }; error = (err: any): void => { console.error(err); }; ...
This is a unit test of a component that has Store as a dependency. Here, we are creating a new class called MockStore that is injected into our component instead of the usual Store. import { Injectable } from '@angular/core'; import { TestBed, async} from '@angular/core/testing'; import { AppComp...
This is a unit test of a component that has Store as a dependency. Here, we are able to use a store with the default "initial state" while preventing it from actually dispatching actions when store.dispatch() is called. import {TestBed, async} from '@angular/core/testing'; import {AppCom...
service I created post service with postRequest method. import {Injectable} from '@angular/core'; import {Http, Headers, Response} from "@angular/http"; import {PostModel} from "./PostModel"; import 'rxjs/add/operator/map'; import {Observable} from "rxjs"; ...
simple.action.ts import { Action } from '@ngrx/store'; export enum simpleActionTpye { add = "simpleAction_Add", add_Success = "simpleAction_Add_Success" } export class simpleAction { type: simpleActionTpye constructor(public payload: number) { } } ...

Page 1 of 1