diff --git a/src/adapters/index.js b/src/adapters/index.js index 7a6e0ce..036f061 100644 --- a/src/adapters/index.js +++ b/src/adapters/index.js @@ -28,7 +28,7 @@ class Adapters { this.passport = new Passport() this.nodemailer = new Nodemailer() this.jsonFiles = new JSONFiles() - this.bchjs = new BCHJS() + this.bchjs = new BCHJS({ restURL: config.apiServer }) this.config = config this.wallet = new Wallet(localConfig) diff --git a/test/unit/adapters/adapters-index-unit.js b/test/unit/adapters/adapters-index-unit.js index 328f2bb..0f52e11 100644 --- a/test/unit/adapters/adapters-index-unit.js +++ b/test/unit/adapters/adapters-index-unit.js @@ -14,13 +14,14 @@ describe('#adapters', () => { let uut, sandbox beforeEach(() => { - uut = new Adapters() - sandbox = sinon.createSandbox() + uut = new Adapters() }) afterEach(() => { - sandbox.restore() + if (sandbox) { + sandbox.restore() + } }) describe('#start', () => { diff --git a/test/unit/misc/config.js b/test/unit/misc/config.js index 54bce08..b1919d6 100644 --- a/test/unit/misc/config.js +++ b/test/unit/misc/config.js @@ -10,15 +10,23 @@ describe('#config', () => { before(() => { // Backup the current environment setting. currentEnv = process.env.SVC_ENV + // Clear SVC_ENV for the first test to ensure default behavior + delete process.env.SVC_ENV }) after(() => { // Restore the environment setting before starting these tests. - process.env.SVC_ENV = currentEnv + if (currentEnv) { + process.env.SVC_ENV = currentEnv + } else { + delete process.env.SVC_ENV + } }) it('Should return development environment config by default', async () => { - const importedConfig = await import('../../../config/index.js') + // Ensure SVC_ENV is not set for this test + delete process.env.SVC_ENV + const importedConfig = await import('../../../config/index.js?foo=bar0') const config = importedConfig.default // console.log('config: ', config) diff --git a/test/unit/mocks/adapters/wallet.js b/test/unit/mocks/adapters/wallet.js index 09e8378..38f18f1 100644 --- a/test/unit/mocks/adapters/wallet.js +++ b/test/unit/mocks/adapters/wallet.js @@ -17,7 +17,7 @@ class MockBchWallet { this.walletInfoPromise = true; this.walletInfo = mockWallet; this.initialize = async () => {} - this.bchjs = new BCHJS(); + this.bchjs = new BCHJS({ restURL: 'https://free-bch.fullstack.cash/' }); this.burnTokens = async () => { return { success: true, txid: 'txid' }; };