import { Component , Injectable } from '@angular/core' ; import { TestBed , async } from '@angular/core/testing' ; import { Observable } from 'rxjs' ; import { ThyStoreModule , Store } from '../index' ; class StringSelectState { baz : string ; boo : string ; } @ Injectable ( ) class StringSelectStore extends Store < StringSelectState > { constructor ( ) { super ( { baz : 'Hello' , boo : 'Worktile' } ) ; } } @ Component ( { selector : 'my-component-0' , template : '' } ) class StringSelectComponent { state : Observable < StringSelectState > ; subState : Observable < string > ; constructor ( store ) { this . state = store . select ( state => { return state ; } ) as Observable < StringSelectState > ; this . subState = store . select ( ( state ) => { return state . baz ; } ) ; } } describe ( 'select' , ( ) => { it ( 'should select the correct state using string' , async ( ( ) => { TestBed . configureTestingModule ( { imports : [ ThyStoreModule . forRoot ( [ StringSelectStore ] ) ] , declarations : [ StringSelectComponent ] } ) ; const comp = TestBed . createComponent ( StringSelectComponent ) ; comp . componentInstance . state . subscribe ( state => { expect ( state . baz ) . toBe ( 'Hello' ) ; expect ( state . boo ) . toBe ( 'Worktile' ) ; } ) ; comp . componentInstance . subState . subscribe ( state => { expect ( state ) . toBe ( 'Hello' ) ; } ) ; } ) ) ; } ) ;