From e33c62d0ac426be81335931bebb68b18c1cfa0fe Mon Sep 17 00:00:00 2001 From: Gabriel Masclef Date: Tue, 19 Nov 2024 10:37:30 -0300 Subject: [PATCH] unit tests for simplexGetCurrencies --- .../test/integration/server.js | 60 ++++++++++++++++++- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/packages/bitcore-wallet-service/test/integration/server.js b/packages/bitcore-wallet-service/test/integration/server.js index 6d1e558e83..cdc057cb58 100644 --- a/packages/bitcore-wallet-service/test/integration/server.js +++ b/packages/bitcore-wallet-service/test/integration/server.js @@ -13181,6 +13181,62 @@ describe('Wallet service', function() { }); }); + describe('#simplexGetCurrencies', () => { + beforeEach(() => { + req = { + headers: {}, + body: { + env: 'sandbox' + }, + } + }); + + it('should work properly if req is OK', () => { + server.request = fakeRequest; + server.simplexGetCurrencies(req).then(data => { + should.exist(data); + }).catch(err => { + should.not.exist(err); + }); + }); + + it('should work properly if req is OK for web', () => { + req.body.context = 'web'; + server.request = fakeRequest; + server.simplexGetCurrencies(req).then(data => { + should.exist(data); + }).catch(err => { + should.not.exist(err); + }); + }); + + it('should return error if get returns error', () => { + const fakeRequest2 = { + get: (_url, _opts, _cb) => { return _cb(new Error('Error'), null) }, + }; + + server.request = fakeRequest2; + server.simplexGetCurrencies(req).then(data => { + should.not.exist(data); + }).catch(err => { + should.exist(err); + err.message.should.equal('Error'); + }); + }); + + it('should return error if simplex is commented in config', () => { + config.simplex = undefined; + + server.request = fakeRequest; + server.simplexGetCurrencies(req).then(data => { + should.not.exist(data); + }).catch(err => { + should.exist(err); + err.message.should.equal('Simplex missing credentials'); + }); + }); + }); + describe('#simplexGetQuote', () => { beforeEach(() => { req = { @@ -13238,7 +13294,7 @@ describe('Wallet service', function() { }); }); - describe.only('#simplexGetSellQuote', () => { + describe('#simplexGetSellQuote', () => { beforeEach(() => { req = { headers: {}, @@ -13384,7 +13440,7 @@ describe('Wallet service', function() { }); }); - describe.only('#simplexSellPaymentRequest', () => { + describe('#simplexSellPaymentRequest', () => { beforeEach(() => { req = { headers: {},