@@ -32,6 +32,7 @@ import { DecimalPipe } from '../../pipes/decimal.pipe';
3232import { UserDepositService } from '../../services/user-deposit.service' ;
3333import BigNumber from 'bignumber.js' ;
3434import { SharedService } from '../../services/shared.service' ;
35+ import { UserToken } from '../../models/usertoken' ;
3536
3637describe ( 'HeaderComponent' , ( ) => {
3738 let component : HeaderComponent ;
@@ -40,6 +41,7 @@ describe('HeaderComponent', () => {
4041 let notificationService : NotificationService ;
4142 let networkSubject : BehaviorSubject < Network > ;
4243 let balanceSubject : BehaviorSubject < string > ;
44+ let tokensSubject : BehaviorSubject < UserToken [ ] > ;
4345 const raidenAddress = createAddress ( ) ;
4446 const channels = createTestChannels ( ) ;
4547 const tokens = createTestTokens ( ) ;
@@ -57,8 +59,9 @@ describe('HeaderComponent', () => {
5759 raidenServiceMock . getUserToken = ( ) => undefined ;
5860
5961 const tokenPollingMock = stub < TokenPollingService > ( ) ;
62+ tokensSubject = new BehaviorSubject ( tokens ) ;
6063 // @ts -ignore
61- tokenPollingMock . tokens$ = of ( tokens ) ;
64+ tokenPollingMock . tokens$ = tokensSubject . asObservable ( ) ;
6265
6366 const channelPollingMock = stub < ChannelPollingService > ( ) ;
6467 // @ts -ignore
@@ -188,7 +191,21 @@ describe('HeaderComponent', () => {
188191 expect ( balanceText ) . toBe ( '0.75' ) ;
189192 } ) ;
190193
191- it ( 'should show the token on-chain balances in an overlay' , ( ) => {
194+ it ( 'should show the token on-chain balances inside the header for two tokens' , ( ) => {
195+ const twoTokens = createTestTokens ( 2 ) ;
196+ tokensSubject . next ( twoTokens ) ;
197+ fixture . detectChanges ( ) ;
198+
199+ expect (
200+ fixture . debugElement . query ( By . css ( '.balances-button' ) )
201+ ) . toBeFalsy ( ) ;
202+ const balances = fixture . debugElement . queryAll (
203+ By . css ( '.header__balance' )
204+ ) ;
205+ expect ( balances . length ) . toBe ( 5 ) ;
206+ } ) ;
207+
208+ it ( 'should show the token on-chain balances in an overlay for more than two tokens' , ( ) => {
192209 clickElement ( fixture . debugElement , '.balances-button' ) ;
193210 fixture . detectChanges ( ) ;
194211 expect ( component . tokenBalancesOpen ) . toBe ( true ) ;
0 commit comments