diff --git a/package.json b/package.json index 369885a..57ac7bc 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "scripts": { "clean": "rm -rf dist", "build": "npm run clean && tsc -p tsconfig.esm.json && tsc -p tsconfig.cjs.json && bash ./postBuild.sh", - "test": "jest --passWithNoTests" + "test": "jest --passWithNoTests", + "test:watch": "jest --watch --passWithNoTests" }, "main": "dist/cjs/index.js", "module": "dist/mjs/index.js", diff --git a/test/CBAdvancedClient/private.test.ts b/test/CBAdvancedClient/private.test.ts index d80dd2d..b3913cc 100644 --- a/test/CBAdvancedClient/private.test.ts +++ b/test/CBAdvancedClient/private.test.ts @@ -2,8 +2,10 @@ import { CBAdvancedTradeClient } from '../../src/index.js'; describe('CBAdvancedTradeClient PRIVATE', () => { const account = { - key: process.env.CB_ADV_API_KEY_NAME, - secret: process.env.CB_ADV_API_PRIVATE_KEY, + // The new line characters can be a bit unpredictable depending on the OS. + // Simplest is to ensure they're replaced into the correct format (if incorrect). + key: process.env.CB_ADV_API_KEY_NAME?.replace(/\\n/g, '\n'), + secret: process.env.CB_ADV_API_PRIVATE_KEY?.replace(/\\n/g, '\n'), }; const rest = new CBAdvancedTradeClient({ @@ -59,7 +61,7 @@ describe('CBAdvancedTradeClient PRIVATE', () => { whatever: true, }); } catch (e: any) { - // These are deliberatly restricted API keys. If the response is a permission error, it confirms the sign + request was OK and permissions were denied. + // These are deliberately restricted API keys. If the response is a permission error, it confirms the sign + request was OK and permissions were denied. // console.log(`err "${expect.getState().currentTestName}"`, e?.body); const responseBody = e?.body; expect(responseBody).toMatchObject({ diff --git a/test/CBAppClient/private.test.ts b/test/CBAppClient/private.test.ts index 465f320..d856f5c 100644 --- a/test/CBAppClient/private.test.ts +++ b/test/CBAppClient/private.test.ts @@ -4,8 +4,8 @@ let accId = ''; describe('CBAppClient PRIVATE', () => { const account = { - key: process.env.CB_APP_API_KEY_NAME, - secret: process.env.CB_APP_API_PRIVATE_KEY, + key: process.env.CB_APP_API_KEY_NAME?.replace(/\\n/g, '\n'), + secret: process.env.CB_APP_API_PRIVATE_KEY?.replace(/\\n/g, '\n'), }; const rest = new CBAppClient({ @@ -65,13 +65,14 @@ describe('CBAppClient PRIVATE', () => { whatever: true, }); } catch (e: any) { - // These are deliberatly restricted API keys. If the response is a permission error, it confirms the sign + request was OK and permissions were denied. + // These are deliberately restricted API keys. If the response is a permission error, it confirms the sign + request was OK and permissions were denied. // console.log(`err "${expect.getState().currentTestName}"`, e?.body); const responseBody = e?.body.errors[0]; + expect(responseBody).toMatchObject({ - id: 'invalid_scope', + id: expect.any(String), message: expect.any(String), - url: expect.any(String), + // url: expect.any(String), }); } }); diff --git a/test/CBExchangeClient/private.test.ts b/test/CBExchangeClient/private.test.ts index d4a917f..45cf857 100644 --- a/test/CBExchangeClient/private.test.ts +++ b/test/CBExchangeClient/private.test.ts @@ -2,9 +2,9 @@ import { CBExchangeClient } from '../../src/index.js'; describe('CBExchangeClient PRIVATE', () => { const account = { - key: process.env.CB_EXCHANGE_API_KEY_NAME_EXCH, - secret: process.env.CB_EXCHANGE_API_PRIVATE_KEY_EXCH, - passphrase: process.env.CB_EXCHANGE_API_PASSPHRASE_EXCH, + key: process.env.CB_EXCHANGE_API_KEY, + secret: process.env.CB_EXCHANGE_API_SECRET, + passphrase: process.env.CB_EXCHANGE_API_PASSPHRASE, useSandbox: process.env.CB_EXCHANGE_USE_SANDBOX === 'true', }; @@ -48,7 +48,7 @@ describe('CBExchangeClient PRIVATE', () => { test('with params', async () => { const res = await rest.getTransfers({ type: 'deposit' }); - console.log(`res "${expect.getState().currentTestName}"`, res); + // console.log(`res "${expect.getState().currentTestName}"`, res); expect(res).toEqual(expect.arrayContaining([expect.any(Object)])); }); @@ -66,9 +66,9 @@ describe('CBExchangeClient PRIVATE', () => { whatever: true, }); } catch (e: any) { - // These are deliberatly restricted API keys. If the response is a permission error, it confirms the sign + request was OK and permissions were denied. + // These are deliberately restricted API keys. If the response is a permission error, it confirms the sign + request was OK and permissions were denied. // console.log(`err "${expect.getState().currentTestName}"`, e?.body); - console.log(`Error, "${expect.getState().currentTestName}"`, e); + // console.log(`Error, "${expect.getState().currentTestName}"`, e); const responseBody = e?.body; expect(responseBody).toMatchObject({ diff --git a/test/CBInternationalClient/private.test.ts b/test/CBInternationalClient/private.test.ts index 41818cb..85d3c65 100644 --- a/test/CBInternationalClient/private.test.ts +++ b/test/CBInternationalClient/private.test.ts @@ -2,8 +2,8 @@ import { CBInternationalClient } from '../../src/index.js'; describe.skip('CBInternationalClient PRIVATE', () => { const account = { - key: process.env.CB_INTX_API_KEY_NAME, - secret: process.env.CB_INTX_API_PRIVATE_KEY, + key: process.env.CB_INTX_API_KEY, + secret: process.env.CB_INTX_API_SECRET, passphrase: process.env.CB_INTX_API_PASSPHRASE, }; @@ -62,7 +62,7 @@ describe.skip('CBInternationalClient PRIVATE', () => { whatever: true, }); } catch (e: any) { - // These are deliberatly restricted API keys. If the response is a permission error, it confirms the sign + request was OK and permissions were denied. + // These are deliberately restricted API keys. If the response is a permission error, it confirms the sign + request was OK and permissions were denied. // console.log(`err "${expect.getState().currentTestName}"`, e?.body); //console.log('Error, CBINTX, post req:', e); const responseBody = e?.body; diff --git a/test/CBPrimeClient/private.test.ts b/test/CBPrimeClient/private.test.ts index 2d19a17..93eed75 100644 --- a/test/CBPrimeClient/private.test.ts +++ b/test/CBPrimeClient/private.test.ts @@ -2,8 +2,8 @@ import { CBPrimeClient } from '../../src/index.js'; describe.skip('CBPrimeClient PRIVATE', () => { const account = { - key: process.env.CB_PRIME_API_KEY_NAME, - secret: process.env.CB_PRIME_API_PRIVATE_KEY, + key: process.env.CB_PRIME_API_KEY, + secret: process.env.CB_PRIME_API_SECRET, passphrase: process.env.CB_PRIME_API_PASSPHRASE, }; @@ -54,7 +54,7 @@ describe.skip('CBPrimeClient PRIVATE', () => { whatever: true, }); } catch (e: any) { - // These are deliberatly restricted API keys. If the response is a permission error, it confirms the sign + request was OK and permissions were denied. + // These are deliberately restricted API keys. If the response is a permission error, it confirms the sign + request was OK and permissions were denied. // console.log(`err "${expect.getState().currentTestName}"`, e?.body); //console.log('Error, CBPrime, post req:', e); const responseBody = e?.body;