@@ -42,13 +42,11 @@ describe('AccountService', () => {
4242 let account : Account ;
4343 let account2 : Account ;
4444
45- function mockAccountInfo ( withMosaic = false ) : AccountInfo [ ] {
45+ function mockAccountInfo ( withMosaic = false , noNamespace = false ) : AccountInfo [ ] {
4646 const mosaic = new Mosaic ( new MosaicId ( '941299B2B7E1291C' ) , UInt64 . fromUint ( 1 ) ) ;
47- const mosaics = [
48- NetworkCurrencyLocal . createAbsolute ( 1 ) ,
49- NetworkCurrencyPublic . createAbsolute ( 1 ) ,
50- NetworkHarvestLocal . createAbsolute ( 1 ) ,
51- ] ;
47+ const mosaics = noNamespace
48+ ? [ ]
49+ : [ NetworkCurrencyLocal . createAbsolute ( 1 ) , NetworkCurrencyPublic . createAbsolute ( 1 ) , NetworkHarvestLocal . createAbsolute ( 1 ) ] ;
5250 if ( withMosaic ) {
5351 mosaics . push ( mosaic ) ;
5452 }
@@ -116,15 +114,16 @@ describe('AccountService', () => {
116114 return new NamespaceName ( id , name ) ;
117115 }
118116
117+ let mockAccountRepository : AccountRepository ;
119118 before ( ( ) => {
120119 account = TestingAccount ;
121120 account2 = MultisigAccount ;
122- const mockAccountRepository = mock < AccountRepository > ( ) ;
121+ mockAccountRepository = mock < AccountRepository > ( ) ;
123122 const mockNamespaceRepository = mock < NamespaceRepository > ( ) ;
124123 const mockRepoFactory = mock < RepositoryFactory > ( ) ;
125124
126125 when ( mockAccountRepository . getAccountsInfo ( deepEqual ( [ account . address ] ) ) ) . thenReturn ( observableOf ( mockAccountInfo ( ) ) ) ;
127- when ( mockAccountRepository . getAccountsInfo ( deepEqual ( [ account2 . address ] ) ) ) . thenReturn ( observableOf ( mockAccountInfo ( true ) ) ) ;
126+
128127 when ( mockNamespaceRepository . getNamespacesFromAccounts ( deepEqual ( [ account . address ] ) ) ) . thenReturn ( observableOf ( mockNamespaceInfo ( ) ) ) ;
129128 when ( mockNamespaceRepository . getNamespacesFromAccounts ( deepEqual ( [ account2 . address ] ) ) ) . thenReturn (
130129 observableOf ( mockNamespaceInfo ( ) ) ,
@@ -170,6 +169,7 @@ describe('AccountService', () => {
170169 } ) ;
171170
172171 it ( 'should return accountInfo with mosaicId' , async ( ) => {
172+ when ( mockAccountRepository . getAccountsInfo ( deepEqual ( [ account2 . address ] ) ) ) . thenReturn ( observableOf ( mockAccountInfo ( true ) ) ) ;
173173 const result = await accountService . accountInfoWithResolvedMosaic ( [ account2 . address ] ) . toPromise ( ) ;
174174 expect ( result [ 0 ] . resolvedMosaics ) . to . not . be . undefined ;
175175 expect ( result [ 0 ] . resolvedMosaics ! [ 0 ] . namespaceName ?. name ) . to . be . equal ( 'catapult.currency' ) ;
@@ -187,4 +187,13 @@ describe('AccountService', () => {
187187 expect ( result ! [ 1 ] . namespaceName ) . to . be . equal ( 'symbol.xym' ) ;
188188 expect ( result ! [ 2 ] . namespaceName ) . to . be . equal ( 'catapult.harvest' ) ;
189189 } ) ;
190+
191+ it ( 'should return empty resolved namespaceInfo' , async ( ) => {
192+ when ( mockAccountRepository . getAccountsInfo ( deepEqual ( [ account2 . address ] ) ) ) . thenReturn ( observableOf ( mockAccountInfo ( true , true ) ) ) ;
193+ const result = await accountService . accountInfoWithResolvedMosaic ( [ account2 . address ] ) . toPromise ( ) ;
194+ console . log ( result [ 0 ] . resolvedMosaics ) ;
195+ expect ( result ) . to . not . be . undefined ;
196+ expect ( result . length ) . to . be . greaterThan ( 0 ) ;
197+ expect ( result ! [ 0 ] . resolvedMosaics ?. length ) . to . be . equal ( 1 ) ;
198+ } ) ;
190199} ) ;
0 commit comments