|
16 | 16 |
|
17 | 17 | import { deepEqual } from 'assert'; |
18 | 18 | import { expect } from 'chai'; |
| 19 | +import { firstValueFrom } from 'rxjs'; |
19 | 20 | import { take, toArray } from 'rxjs/operators'; |
20 | 21 | import { AccountRepository, MultisigRepository, NamespaceRepository, Order, RepositoryCallError } from '../../src/infrastructure'; |
21 | 22 | import { AccountPaginationStreamer } from '../../src/infrastructure/paginationStreamer'; |
@@ -164,79 +165,77 @@ describe('AccountHttp', () => { |
164 | 165 |
|
165 | 166 | describe('getAccountInfo', () => { |
166 | 167 | it('should return account data given a NEM Address', async () => { |
167 | | - const accountInfo = await accountRepository.getAccountInfo(accountAddress).toPromise(); |
| 168 | + const accountInfo = await firstValueFrom(accountRepository.getAccountInfo(accountAddress)); |
168 | 169 | expect(accountInfo.publicKey).to.be.equal(accountPublicKey); |
169 | 170 |
|
170 | | - const merkleInfo = await accountRepository.getAccountInfoMerkle(accountInfo.address).toPromise(); |
| 171 | + const merkleInfo = await firstValueFrom(accountRepository.getAccountInfoMerkle(accountInfo.address)); |
171 | 172 | expect(merkleInfo.raw).to.not.be.undefined; |
172 | 173 | }); |
173 | 174 | }); |
174 | 175 |
|
175 | 176 | describe('getAccountsInfo', () => { |
176 | 177 | it('should return account data given a NEM Address', async () => { |
177 | | - const accountsInfo = await accountRepository.getAccountsInfo([accountAddress]).toPromise(); |
| 178 | + const accountsInfo = await firstValueFrom(accountRepository.getAccountsInfo([accountAddress])); |
178 | 179 | expect(accountsInfo[0].publicKey).to.be.equal(accountPublicKey); |
179 | 180 | }); |
180 | 181 | }); |
181 | 182 |
|
182 | 183 | describe('searchAccount', () => { |
183 | 184 | it('should return account info', async () => { |
184 | | - const info = await accountRepository.search({}).toPromise(); |
| 185 | + const info = await firstValueFrom(accountRepository.search({})); |
185 | 186 | expect(info.data.length).to.be.greaterThan(0); |
186 | 187 | }); |
187 | 188 | }); |
188 | 189 |
|
189 | 190 | describe('searchAccount with streamer', () => { |
190 | 191 | it('should return account info', async () => { |
191 | 192 | const streamer = new AccountPaginationStreamer(accountRepository); |
192 | | - const infoStreamer = await streamer |
193 | | - .search({ pageSize: 20, order: Order.Asc, orderBy: AccountOrderBy.Id }) |
194 | | - .pipe(take(20), toArray()) |
195 | | - .toPromise(); |
196 | | - const info = await accountRepository.search({ pageSize: 20, order: Order.Asc, orderBy: AccountOrderBy.Id }).toPromise(); |
| 193 | + const infoStreamer = await firstValueFrom( |
| 194 | + streamer.search({ pageSize: 20, order: Order.Asc, orderBy: AccountOrderBy.Id }).pipe(take(20), toArray()), |
| 195 | + ); |
| 196 | + const info = await firstValueFrom(accountRepository.search({ pageSize: 20, order: Order.Asc, orderBy: AccountOrderBy.Id })); |
197 | 197 | expect(infoStreamer.length).to.be.greaterThan(0); |
198 | 198 | deepEqual(infoStreamer[0], info.data[0]); |
199 | 199 | }); |
200 | 200 | }); |
201 | 201 |
|
202 | 202 | describe('transactions', () => { |
203 | 203 | it('should not return accounts when account does not exist', () => { |
204 | | - return accountRepository |
205 | | - .getAccountInfo(Account.generateNewAccount(networkType).address) |
206 | | - .toPromise() |
207 | | - .then( |
208 | | - () => { |
209 | | - return Promise.reject('should fail!'); |
210 | | - }, |
211 | | - (err) => { |
212 | | - const error: RepositoryCallError = JSON.parse(err.message); |
213 | | - expect(error.statusCode).to.be.eq(404); |
214 | | - expect(error.statusMessage).to.be.eq('Not Found'); |
215 | | - return Promise.resolve(); |
216 | | - }, |
217 | | - ); |
| 204 | + return firstValueFrom(accountRepository.getAccountInfo(Account.generateNewAccount(networkType).address)).then( |
| 205 | + () => { |
| 206 | + return Promise.reject('should fail!'); |
| 207 | + }, |
| 208 | + (err) => { |
| 209 | + const error: RepositoryCallError = JSON.parse(err.message); |
| 210 | + expect(error.statusCode).to.be.eq(404); |
| 211 | + expect(error.statusMessage).to.be.eq('Not Found'); |
| 212 | + return Promise.resolve(); |
| 213 | + }, |
| 214 | + ); |
218 | 215 | }); |
219 | 216 | }); |
220 | 217 |
|
221 | 218 | describe('getAddressNames', () => { |
222 | 219 | it('should call getAddressNames successfully', async () => { |
223 | | - const addressNames = await namespaceRepository.getAccountsNames([accountAddress]).toPromise(); |
| 220 | + const addressNames = await firstValueFrom(namespaceRepository.getAccountsNames([accountAddress])); |
224 | 221 | expect(addressNames.length).to.be.greaterThan(0); |
225 | 222 | }); |
226 | 223 | }); |
227 | 224 |
|
228 | 225 | describe('getMultisigAccountGraphInfo', () => { |
229 | 226 | it('should call getMultisigAccountGraphInfo successfully', async () => { |
230 | 227 | await new Promise((resolve) => setTimeout(resolve, 3000)); |
231 | | - const multisigAccountGraphInfo = await multisigRepository |
232 | | - .getMultisigAccountGraphInfo(multisigAccount.publicAccount.address) |
233 | | - .toPromise(); |
| 228 | + const multisigAccountGraphInfo = await firstValueFrom( |
| 229 | + multisigRepository.getMultisigAccountGraphInfo(multisigAccount.publicAccount.address), |
| 230 | + ); |
234 | 231 | expect(multisigAccountGraphInfo.multisigEntries.get(0)![0].accountAddress.plain()).to.be.equal(multisigAccount.address.plain()); |
235 | 232 | }); |
236 | 233 | }); |
237 | 234 | describe('getMultisigAccountInfo', () => { |
238 | 235 | it('should call getMultisigAccountInfo successfully', async () => { |
239 | | - const multisigAccountInfo = await multisigRepository.getMultisigAccountInfo(multisigAccount.publicAccount.address).toPromise(); |
| 236 | + const multisigAccountInfo = await firstValueFrom( |
| 237 | + multisigRepository.getMultisigAccountInfo(multisigAccount.publicAccount.address), |
| 238 | + ); |
240 | 239 | expect(multisigAccountInfo.accountAddress.plain()).to.be.equal(multisigAccount.address.plain()); |
241 | 240 | }); |
242 | 241 | }); |
|
0 commit comments