From 6a690e652758075453cf382f7c69372e0b2ba05c Mon Sep 17 00:00:00 2001 From: anti-malware Date: Sun, 14 Feb 2021 01:34:41 +0700 Subject: [PATCH] update test and change merge to object.assign --- __test__/coreApi.test.ts | 4 ++-- __test__/iris.test.ts | 16 +++++++--------- package.json | 6 +++--- src/lib/apiConfig.ts | 2 +- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/__test__/coreApi.test.ts b/__test__/coreApi.test.ts index 309acba..be5778b 100644 --- a/__test__/coreApi.test.ts +++ b/__test__/coreApi.test.ts @@ -47,8 +47,8 @@ describe('CoreApi', () => { expect(isType(res.status_code)).toStrictEqual('string') expect(isType(res.token_id)).toStrictEqual('string') expect(res.status_code).toStrictEqual('200') - tokenId = res.token_id done() + tokenId = res.token_id }) it('able to card register cc', async (done) => { @@ -65,8 +65,8 @@ describe('CoreApi', () => { expect(isType(res.status_code)).toStrictEqual('string') expect(isType(res.saved_token_id)).toStrictEqual('string') expect(res.status_code).toStrictEqual('200') - savedTokenId = res.saved_token_id done() + savedTokenId = res.saved_token_id }) it('fail to card point inquiry 402', () => { diff --git a/__test__/iris.test.ts b/__test__/iris.test.ts index 01b534e..f02957a 100644 --- a/__test__/iris.test.ts +++ b/__test__/iris.test.ts @@ -70,16 +70,14 @@ describe('Iris.js', () => { done() }) - it('fail 400 to createBeneficiaries with unset api key', () => { + it('fail 400 to createBeneficiaries with unset api key', (done) => { const spyIris = jest.spyOn(iris, 'createBeneficiaries') - return iris - .createBeneficiaries({}) - .then((res) => { - expect(spyIris).toHaveBeenCalled() - expect(spyIris).toHaveBeenCalledTimes(1) - expect(res).toStrictEqual(null) - }) - .catch((e) => expect(e.message).toMatch(/400/)) + return iris.createBeneficiaries({}).catch((e) => { + expect(spyIris).toHaveBeenCalled() + expect(spyIris).toHaveBeenCalledTimes(1) + expect(e.message).toMatch(/400/) + done() + }) }) it('fail to createBeneficiaries: account duplicated / already been taken', () => { diff --git a/package.json b/package.json index b4aebbd..e01d4bf 100644 --- a/package.json +++ b/package.json @@ -14,8 +14,8 @@ "test:watch": "jest --watchAll", "test:coverage": "jest --coverage", "test:coveralls": "jest --coverage && coveralls < coverage/lcov.info", - "lint": "eslint src/**/*.{ts,spec.ts,test.ts} --fix", - "format": "prettier src/**/*.{ts,spec.ts,test.ts} --write", + "lint": "eslint src/**/*.ts --fix", + "format": "prettier src/**/*.ts --write", "lint:fix": "npm run format && npm run lint" }, "author": { @@ -54,7 +54,7 @@ "devDependencies": { "@types/axios": "^0.14.0", "@types/jest": "^26.0.20", - "@types/lodash": "^4.14.167", + "@types/lodash": "^4.14.168", "@types/node": "^14.14.20", "@typescript-eslint/eslint-plugin": "^4.12.0", "@typescript-eslint/parser": "^4.12.0", diff --git a/src/lib/apiConfig.ts b/src/lib/apiConfig.ts index 114969b..76f7b34 100644 --- a/src/lib/apiConfig.ts +++ b/src/lib/apiConfig.ts @@ -54,7 +54,7 @@ export class ApiConfig { } this.parsedOptions = _.pick(options, ['isProduction', 'serverKey', 'clientKey']) - this.mergedConfig = _.merge({}, currentConfig, this.parsedOptions) + this.mergedConfig = Object.assign(currentConfig, this.parsedOptions) this.isProduction = options ? this.mergedConfig.isProduction : this.isProduction this.serverKey = options ? this.mergedConfig.serverKey : this.serverKey