import { Injectable } from '@angular/core' ; import { ICookieService } from '../client/app/shared/services/cookie.service' ; import { BehaviorSubject } from 'rxjs/BehaviorSubject' ; @ Injectable ( ) export class MockCookieService implements ICookieService { private cookieSource = new BehaviorSubject < { [ key ] : any ; } > ( this . getAll ( ) ) ; public cookies$ = this . cookieSource . asObservable ( ) ; public mockCookieStore : any = { } ; get ( name ) { return this . mockCookieStore [ name ] ; } getAll ( ) { return this . mockCookieStore || { } ; } set ( name , value , options ? ) { this . mockCookieStore [ name ] = value ; this . cookieSource . next ( this . getAll ( ) ) ; } remove ( name , options ? ) { const { [ name ] : omit , ... newObject } = this . mockCookieStore ; this . mockCookieStore = newObject ; this . cookieSource . next ( this . getAll ( ) ) ; } }